diff --git a/POE-Component-SSLify-0.16.tar.gz b/POE-Component-SSLify-0.16.tar.gz index 621faeb..5dbaf07 100644 Binary files a/POE-Component-SSLify-0.16.tar.gz and b/POE-Component-SSLify-0.16.tar.gz differ diff --git a/examples/server.pl b/examples/server.pl index 52f4454..9638309 100755 --- a/examples/server.pl +++ b/examples/server.pl @@ -39,7 +39,7 @@ $socket = Server_SSLify( $socket ); # testing stuff - warn "got connection from: " . inet_ntoa( ( unpack_sockaddr_in( getpeername( SSLify_GetSocket( $socket ) ) ) )[1] ) . " cipher type: " . SSLify_GetCipher( $socket ); + warn "got connection from: " . inet_ntoa( ( unpack_sockaddr_in( getpeername( SSLify_GetSocket( $socket ) ) ) )[1] ) . " cipher type: " . SSLify_GetCipher( $socket ) . "\n"; # Hand it off to ReadWrite my $wheel = POE::Wheel::ReadWrite->new( @@ -65,6 +65,10 @@ 'Got_Input' => sub { # ARG0: The Line, ARG1: Wheel ID + # testing stuff + my $socket = $_[HEAP]->{'WHEELS'}->{ $_[ARG1] }->get_output_handle(); + warn "got input from: " . inet_ntoa( ( unpack_sockaddr_in( getpeername( SSLify_GetSocket( $socket ) ) ) )[1] ) . " cipher type: (" . SSLify_GetCipher( $socket ) . ") input: '$_[ARG0]'\n"; + # Send back to the client the line! $_[HEAP]->{'WHEELS'}->{ $_[ARG1] }->put( $_[ARG0] ); return 1; diff --git a/examples/serverclient.pl b/examples/serverclient.pl index d81b7a7..1861eb6 100755 --- a/examples/serverclient.pl +++ b/examples/serverclient.pl @@ -38,13 +38,13 @@ my $socket = $_[ ARG0 ]; # testing stuff - warn "got connection from: " . inet_ntoa( ( unpack_sockaddr_in( getpeername( $socket ) ) )[1] ) . " - commencing Server_SSLify()"; + warn "got connection from: " . inet_ntoa( ( unpack_sockaddr_in( getpeername( $socket ) ) )[1] ) . " - commencing Server_SSLify()\n"; # SSLify it! $socket = Server_SSLify( $socket ); # testing stuff - warn "SSLified: " . inet_ntoa( ( unpack_sockaddr_in( getpeername( SSLify_GetSocket( $socket ) ) ) )[1] ) . " cipher type: " . SSLify_GetCipher( $socket ); + warn "SSLified: " . inet_ntoa( ( unpack_sockaddr_in( getpeername( SSLify_GetSocket( $socket ) ) ) )[1] ) . " cipher type: (" . SSLify_GetCipher( $socket ) . ")\n"; # Hand it off to ReadWrite my $wheel = POE::Wheel::ReadWrite->new( @@ -68,6 +68,10 @@ }, 'Got_Input' => sub { # ARG0: The Line, ARG1: Wheel ID + + # testing stuff + my $socket = $_[HEAP]->{'WHEELS'}->{ $_[ARG1] }->get_output_handle(); + warn "got input from: " . inet_ntoa( ( unpack_sockaddr_in( getpeername( SSLify_GetSocket( $socket ) ) ) )[1] ) . " cipher type: (" . SSLify_GetCipher( $socket ) . ") input: '$_[ARG0]'\n"; # Send back to the client the line! $_[HEAP]->{'WHEELS'}->{ $_[ARG1] }->put( $_[ARG0] ); @@ -128,12 +132,12 @@ # ARG0 = Socket, ARG1 = Remote Address, ARG2 = Remote Port my $socket = $_[ ARG0 ]; - warn "Connected to server, commencing Client_SSLify()"; + warn "Connected to server, commencing Client_SSLify()\n"; # SSLify it! $socket = Client_SSLify( $socket ); - warn "SSLified the connection to the server"; + warn "SSLified the connection to the server\n"; # Hand it off to ReadWrite my $wheel = POE::Wheel::ReadWrite->new( diff --git a/lib/POE/Component/SSLify/ClientHandle.pm b/lib/POE/Component/SSLify/ClientHandle.pm index 440a15f..e7b73b3 100644 --- a/lib/POE/Component/SSLify/ClientHandle.pm +++ b/lib/POE/Component/SSLify/ClientHandle.pm @@ -19,7 +19,7 @@ # create a context, if necessary if ( ! defined $ctx ) { - $ctx = POE::Component::SSLify::createSSLcontext( undef, undef, $version, $options ); + $ctx = POE::Component::SSLify::_createSSLcontext( undef, undef, $version, $options ); } my $ssl = Net::SSLeay::new( $ctx ) or die_now( "Failed to create SSL $!" ); diff --git a/lib/POE/Component/SSLify.pm b/lib/POE/Component/SSLify.pm index 74f11a1..5209329 100644 --- a/lib/POE/Component/SSLify.pm +++ b/lib/POE/Component/SSLify.pm @@ -433,6 +433,21 @@ Example: print "SSL Cipher is: " . SSLify_GetCipher( $sslified_sock ) . "\n"; + NOTE: Doing this immediately after Client_SSLify or Server_SSLify will result in "(NONE)" because the SSL handshake + is not done yet. The socket is nonblocking, so you will have to wait a little bit for it to get ready. + apoc@blackhole:~/mygit/perl-poe-sslify/examples$ perl serverclient.pl + got connection from: 127.0.0.1 - commencing Server_SSLify() + SSLified: 127.0.0.1 cipher type: ((NONE)) + Connected to server, commencing Client_SSLify() + SSLified the connection to the server + Connected to SSL server + Input: hola + got input from: 127.0.0.1 cipher type: (AES256-SHA) input: 'hola' + Got Reply: hola + Input: ^C + stopped at serverclient.pl line 126. + + =head2 SSLify_GetSocket Returns the actual socket used by the SSLified socket, useful for stuff like getpeername()/getsockname() diff --git a/t/simple.t b/t/simple.t index 8bee642..b26fc8b 100644 --- a/t/simple.t +++ b/t/simple.t @@ -1,4 +1,6 @@ #!/usr/bin/perl + +# Thanks to ASCENT for this test! use strict; use warnings;