Package list libpoe-component-sslify-perl / 9549e30
tweak example a bit and add note about SSLify_GetCipher Apocalypse 11 years ago
6 changed file(s) with 31 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
3838 $socket = Server_SSLify( $socket );
3939
4040 # testing stuff
41 warn "got connection from: " . inet_ntoa( ( unpack_sockaddr_in( getpeername( SSLify_GetSocket( $socket ) ) ) )[1] ) . " cipher type: " . SSLify_GetCipher( $socket );
41 warn "got connection from: " . inet_ntoa( ( unpack_sockaddr_in( getpeername( SSLify_GetSocket( $socket ) ) ) )[1] ) . " cipher type: " . SSLify_GetCipher( $socket ) . "\n";
4242
4343 # Hand it off to ReadWrite
4444 my $wheel = POE::Wheel::ReadWrite->new(
6464 'Got_Input' => sub {
6565 # ARG0: The Line, ARG1: Wheel ID
6666
67 # testing stuff
68 my $socket = $_[HEAP]->{'WHEELS'}->{ $_[ARG1] }->get_output_handle();
69 warn "got input from: " . inet_ntoa( ( unpack_sockaddr_in( getpeername( SSLify_GetSocket( $socket ) ) ) )[1] ) . " cipher type: (" . SSLify_GetCipher( $socket ) . ") input: '$_[ARG0]'\n";
70
6771 # Send back to the client the line!
6872 $_[HEAP]->{'WHEELS'}->{ $_[ARG1] }->put( $_[ARG0] );
6973 return 1;
3737 my $socket = $_[ ARG0 ];
3838
3939 # testing stuff
40 warn "got connection from: " . inet_ntoa( ( unpack_sockaddr_in( getpeername( $socket ) ) )[1] ) . " - commencing Server_SSLify()";
40 warn "got connection from: " . inet_ntoa( ( unpack_sockaddr_in( getpeername( $socket ) ) )[1] ) . " - commencing Server_SSLify()\n";
4141
4242 # SSLify it!
4343 $socket = Server_SSLify( $socket );
4444
4545 # testing stuff
46 warn "SSLified: " . inet_ntoa( ( unpack_sockaddr_in( getpeername( SSLify_GetSocket( $socket ) ) ) )[1] ) . " cipher type: " . SSLify_GetCipher( $socket );
46 warn "SSLified: " . inet_ntoa( ( unpack_sockaddr_in( getpeername( SSLify_GetSocket( $socket ) ) ) )[1] ) . " cipher type: (" . SSLify_GetCipher( $socket ) . ")\n";
4747
4848 # Hand it off to ReadWrite
4949 my $wheel = POE::Wheel::ReadWrite->new(
6767 },
6868 'Got_Input' => sub {
6969 # ARG0: The Line, ARG1: Wheel ID
70
71 # testing stuff
72 my $socket = $_[HEAP]->{'WHEELS'}->{ $_[ARG1] }->get_output_handle();
73 warn "got input from: " . inet_ntoa( ( unpack_sockaddr_in( getpeername( SSLify_GetSocket( $socket ) ) ) )[1] ) . " cipher type: (" . SSLify_GetCipher( $socket ) . ") input: '$_[ARG0]'\n";
7074
7175 # Send back to the client the line!
7276 $_[HEAP]->{'WHEELS'}->{ $_[ARG1] }->put( $_[ARG0] );
127131 # ARG0 = Socket, ARG1 = Remote Address, ARG2 = Remote Port
128132 my $socket = $_[ ARG0 ];
129133
130 warn "Connected to server, commencing Client_SSLify()";
134 warn "Connected to server, commencing Client_SSLify()\n";
131135
132136 # SSLify it!
133137 $socket = Client_SSLify( $socket );
134138
135 warn "SSLified the connection to the server";
139 warn "SSLified the connection to the server\n";
136140
137141 # Hand it off to ReadWrite
138142 my $wheel = POE::Wheel::ReadWrite->new(
1818
1919 # create a context, if necessary
2020 if ( ! defined $ctx ) {
21 $ctx = POE::Component::SSLify::createSSLcontext( undef, undef, $version, $options );
21 $ctx = POE::Component::SSLify::_createSSLcontext( undef, undef, $version, $options );
2222 }
2323
2424 my $ssl = Net::SSLeay::new( $ctx ) or die_now( "Failed to create SSL $!" );
432432 Example:
433433 print "SSL Cipher is: " . SSLify_GetCipher( $sslified_sock ) . "\n";
434434
435 NOTE: Doing this immediately after Client_SSLify or Server_SSLify will result in "(NONE)" because the SSL handshake
436 is not done yet. The socket is nonblocking, so you will have to wait a little bit for it to get ready.
437 apoc@blackhole:~/mygit/perl-poe-sslify/examples$ perl serverclient.pl
438 got connection from: 127.0.0.1 - commencing Server_SSLify()
439 SSLified: 127.0.0.1 cipher type: ((NONE))
440 Connected to server, commencing Client_SSLify()
441 SSLified the connection to the server
442 Connected to SSL server
443 Input: hola
444 got input from: 127.0.0.1 cipher type: (AES256-SHA) input: 'hola'
445 Got Reply: hola
446 Input: ^C
447 stopped at serverclient.pl line 126.
448
449
435450 =head2 SSLify_GetSocket
436451
437452 Returns the actual socket used by the SSLified socket, useful for stuff like getpeername()/getsockname()
00 #!/usr/bin/perl
1
2 # Thanks to ASCENT for this test!
13
24 use strict;
35 use warnings;