Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

dzilification and insitu test and remove old crufty NBIO code

  • Loading branch information...
commit 07f4c2211d5616dceb726fc7c1b086663c7cba49 1 parent dcdebeb
@apocalypse authored
Showing with 277 additions and 428 deletions.
  1. +2 −4 .gitignore
  2. +0 −49 Build.PL
  3. +27 −20 Changes
  4. +0 −24 MANIFEST
  5. +0 −30 MANIFEST.SKIP
  6. +2 −0  dist.ini
  7. +0 −1  examples/client.pl
  8. +0 −1  examples/server.pl
  9. +0 −1  examples/serverclient.pl
  10. +27 −157 lib/POE/Component/SSLify.pm
  11. +3 −29 lib/POE/Component/SSLify/ClientHandle.pm
  12. +2 −29 lib/POE/Component/SSLify/ServerHandle.pm
  13. 0  { → releases}/POE-Component-SSLify-0.01.tar.gz
  14. 0  { → releases}/POE-Component-SSLify-0.02.tar.gz
  15. 0  { → releases}/POE-Component-SSLify-0.03.tar.gz
  16. 0  { → releases}/POE-Component-SSLify-0.04.tar.gz
  17. 0  { → releases}/POE-Component-SSLify-0.05.tar.gz
  18. 0  { → releases}/POE-Component-SSLify-0.06.tar.gz
  19. 0  { → releases}/POE-Component-SSLify-0.07.tar.gz
  20. 0  { → releases}/POE-Component-SSLify-0.08.tar.gz
  21. 0  { → releases}/POE-Component-SSLify-0.09.tar.gz
  22. 0  { → releases}/POE-Component-SSLify-0.10.tar.gz
  23. 0  { → releases}/POE-Component-SSLify-0.11.tar.gz
  24. 0  { → releases}/POE-Component-SSLify-0.12.tar.gz
  25. 0  { → releases}/POE-Component-SSLify-0.13.tar.gz
  26. 0  { → releases}/POE-Component-SSLify-0.14.tar.gz
  27. 0  { → releases}/POE-Component-SSLify-0.15.tar.gz
  28. 0  { → releases}/POE-Component-SSLify-0.16.tar.gz
  29. 0  { → releases}/POE-Component-SSLify-0.17.tar.gz
  30. 0  { → releases}/POE-Component-SSLify-0.18.tar.gz
  31. 0  { → releases}/POE-Component-SSLify-0.19.tar.gz
  32. 0  { → releases}/POE-Component-SSLify-0.20.tar.gz
  33. +0 −20 t/1_load.t
  34. +23 −32 t/{2_simple.t → 1_simple.t}
  35. +6 −19 t/{3_renegotiate.t → 2_renegotiate.t}
  36. +185 −0 t/3_insitu.t
  37. +0 −12 t/apocalypse.t
View
6 .gitignore
@@ -1,4 +1,2 @@
-LICENSE
-META.yml
-README
-Makefile.PL
+/POE-Component-SSLify-*
+/.build/
View
49 Build.PL
@@ -1,49 +0,0 @@
-# Build.PL
-use strict; use warnings;
-use Module::Build;
-
-my $build = Module::Build->new(
- # look up Module::Build::API for the info!
- 'dynamic_config' => 0,
- 'module_name' => 'POE::Component::SSLify',
- 'license' => 'perl',
-
- 'dist_abstract' => 'SSL in the world of POE made easy',
- 'dist_author' => 'Apocalypse <APOCAL@cpan.org>',
-
- 'create_packlist' => 1,
- 'create_makefile_pl' => 'traditional',
- 'create_readme' => 1,
- 'create_license' => 1,
- 'sign' => 0,
-
- 'test_files' => 't/*.t',
-
- 'requires' => {
- # Networking
- 'Net::SSLeay' => '1.36',
-
- # minimum perl version
- 'perl' => '5.006',
- },
-
- 'build_requires' => {
- # For the t/simple.t test
- 'POE' => '1.267',
- 'POE::Component::Client::TCP' => 0,
- 'POE::Component::Server::TCP' => 0,
- },
-
- # include the standard stuff in META.yml
- 'meta_merge' => {
- 'resources' => {
- 'license' => 'http://dev.perl.org/licenses/',
- 'homepage' => 'http://search.cpan.org/dist/POE-Component-SSLify',
- 'bugtracker' => 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=POE-Component-SSLify',
- 'repository' => 'http://github.com/apocalypse/perl-poe-sslify',
- },
- },
-);
-
-# all done!
-$build->create_build_script;
View
47 Changes
@@ -1,24 +1,31 @@
Revision history for Perl extension POE::Component::SSLify.
-* 0.20
+{{$NEXT}}
+
+ Converted to Dist::Zilla for the release process!
+ Add a test for in-situ sslification, thanks mordy@irc!
+ Add prereq for IO::Handle 1.28 to get sane $socket->blocking( 0 ) behavior on MSWin32
+ Remove crufty old code for nonblocking and use $socket->blocking() instead
+
+0.20
Split up the simple.t test into 2 tests for clarity, and added more diag messages for renegotiate, thanks HMBRAND!
-* 0.19
+0.19
Fixed a warning generated by POE::Component::Client::TCP in t/simple.t, thanks HMBRAND!
-* 0.18
+0.18
Bumped POE dep to at least 1.267 for t/simple.t - thanks CPANTesters!
Minor typo fixes in POD/Build.PL
-* 0.17
+0.17
Fixed the t/simple.t test to PASS on FreeBSD because Net::SSLeay::renegotiate was buggy on it, thanks CPANTesters!
Added note about OpenSSL functions in the POD.
-* 0.16
+0.16
Updated the nonblocking code to be production-ready, thanks ASCENT!
Removed the NONBLOCKING() sub, this module is now always nonblocking.
@@ -27,7 +34,7 @@ Revision history for Perl extension POE::Component::SSLify.
Misc kwalitee and POD fixes.
Bumped Net::SSLeay prereq to 1.36 so we have the latest SSL stuff to ensure sanity :)
-* 0.15
+0.15
Added "examples/serverclient.pl" to track down same-process sslification problems, thanks LotR!
@@ -37,7 +44,7 @@ Revision history for Perl extension POE::Component::SSLify.
Added experimental NONBLOCKING code, thanks ASCENT for the motivation!
-* 0.14
+0.14
removed Test::* modules from dependency list, thanks BINGOS - RT #36725
@@ -45,15 +52,15 @@ Revision history for Perl extension POE::Component::SSLify.
added Build.PL
-* 0.13
+0.13
POD typo errors in SSLify_ContextCreate - thanks ASCENT!
-* 0.12
+0.12
Kwalitee-related fixes
-* 0.11
+0.11
allowed setting of client-side context ( $ctx ) object - thanks RT #34442
@@ -65,47 +72,47 @@ Revision history for Perl extension POE::Component::SSLify.
backported Net::SSLeay's removal of %Filenum_Objects hash
-* 0.10
+0.10
More tweaks of POD - finally close RT #31238
Added SSL version support - thanks RT #31492
Added SSL CTX option support as a side effect
Added client.pl example with ReadLine support
-* 0.09
+0.09
Minor tweak of POD to enable better distro building - thanks RT #31238
-* 0.08
+0.08
Added support for BINMODE - thanks RT #27117
-* 0.07
+0.07
Fixed undefined $info - thanks RT #22372
-* 0.06
+0.06
Kwalitee-related fixes
-* 0.05
+0.05
Finally use a Changes file - thanks RT #18981
Documentation tweaks
Upgraded Net::SSLeay requirement to 1.30 to help Win32 problems
-* 0.04
+0.04
Added new functions to extract data from the SSL socket -> GetCipher and GetSocket
In the case somebody knows Net::SSLeay more than me, added GetCTX to return the server-side CTX object
Removed the dependency on Net::SSLeay::Handle
-* 0.03
+0.03
First stab at the server-side code, help me test it out!
Refactored SSLify() into client/server side, so update your program accordingly!
-* 0.02
+0.02
Made sure the IO::Handle way was used only on MSWin32
@@ -114,6 +121,6 @@ Revision history for Perl extension POE::Component::SSLify.
Oops, forgot to override _get_self and _get_ssl
Fixed a nasty leak issue
-* 0.01
+0.01
Initial release
View
24 MANIFEST
@@ -1,24 +0,0 @@
-Build.PL
-MANIFEST
-MANIFEST.SKIP
-README
-Makefile.PL
-META.yml
-Changes
-LICENSE
-
-lib/POE/Component/SSLify.pm
-lib/POE/Component/SSLify/ClientHandle.pm
-lib/POE/Component/SSLify/ServerHandle.pm
-
-examples/client.pl
-examples/server.pl
-examples/serverclient.pl
-
-mylib/example.crt
-mylib/example.key
-
-t/1_load.t
-t/2_simple.t
-t/3_renegotiate.t
-t/apocalypse.t
View
30 MANIFEST.SKIP
@@ -1,30 +0,0 @@
-# skip Eclipse IDE stuff
-\.includepath$
-\.project$
-\.settings/
-
-# Avoid version control files.
-\B\.svn\b
-\B\.git\b
-^\.gitignore$
-
-# Avoid Makemaker generated and utility files.
-\bMakefile$
-\bblib/
-\bMakeMaker-\d
-\bpm_to_blib$
-
-# Avoid Module::Build generated and utility files.
-\bBuild$
-\b_build/
-^MYMETA.yml$
-
-# Avoid temp and backup files.
-~$
-\.old$
-\#$
-\b\.#
-\.bak$
-
-# our tarballs
-\.tar\.gz$
View
2  dist.ini
@@ -0,0 +1,2 @@
+name = POE-Component-SSLify
+[@Apocalyptic]
View
1  examples/client.pl
@@ -1,5 +1,4 @@
#!/usr/bin/perl
-use strict; use warnings;
use POE;
use POE::Component::SSLify qw( Client_SSLify );
View
1  examples/server.pl
@@ -1,5 +1,4 @@
#!/usr/bin/perl
-use strict; use warnings;
use POE;
use Socket qw( inet_ntoa unpack_sockaddr_in );
View
1  examples/serverclient.pl
@@ -1,5 +1,4 @@
#!/usr/bin/perl
-use strict; use warnings;
use POE;
use Socket qw( inet_ntoa unpack_sockaddr_in );
View
184 lib/POE/Component/SSLify.pm
@@ -1,17 +1,12 @@
package POE::Component::SSLify;
-use strict; use warnings;
-# Initialize our version
-use vars qw( $VERSION );
-$VERSION = '0.20';
+# ABSTRACT: Makes using SSL in the world of POE easy!
# We need Net::SSLeay or all's a failure!
BEGIN {
eval {
- require Net::SSLeay;
-
# We need >= 1.36 because it contains a lot of important fixes
- Net::SSLeay->import( 1.36 );
+ use Net::SSLeay 1.36 qw( die_now die_if_ssl_error );
};
# Check for errors...
@@ -19,7 +14,7 @@ BEGIN {
# Oh boy!
die $@;
} else {
- # Finally, load our subclass :)
+ # Finally, load our subclasses :)
# ClientHandle isa ServerHandle so it will get loaded automatically
require POE::Component::SSLify::ClientHandle;
@@ -39,69 +34,14 @@ use vars qw( @ISA @EXPORT_OK );
# Bring in some socket-related stuff
use Symbol qw( gensym );
-use POSIX qw( F_GETFL F_SETFL O_NONBLOCK EAGAIN EWOULDBLOCK );
-# We need the server-side stuff
-use Net::SSLeay qw( die_now die_if_ssl_error );
+# we need IO 1.24 for it's win32 fixes but it includes IO::Handle 1.27_02 which is dev...
+# unfortunately we have to jump to IO 1.25 which includes IO::Handle 1.28... argh!
+use IO::Handle 1.28;
# The server-side CTX stuff
my $ctx = undef;
-# Helper sub to set nonblocking on a handle
-sub _NonBlocking {
- my $socket = shift;
-
- # ActiveState Perl 5.8.0 dislikes the Win32-specific code to make
- # a socket blocking, so we use IO::Handle's blocking(0) method.
- # Perl 5.005_03 doesn't like blocking(), so we only use it in
- # 5.8.0 and beyond.
- if ( $] >= 5.008 and $^O eq 'MSWin32' ) {
- # TODO investigate this?
-# <kmx> kthakore: Apocalypse: FYI - as regards no-blocking socket dark magic commited to FB while ago - IO::Socket 1.24 (=May/2009) and later supports on Win32 simply $socket->blocking(0);
-# <Apocalypse> kmx: Ah didn't know that - maybe I can use that :)
-# <kmx> Apocalypse: I uderstand that used workaround is from pre IO::Socket 1.24 times
-# <Apocalypse> Ah, my code already did that eh
-# <Apocalypse> if ( $] >= 5.008 and $^O eq 'MSWin32' ) {
-# <Apocalypse> But maybe 5.008 check isn't enough?
-# <kmx> Apocalypse: You'd better check version of IO - see changelog http://cpansearch.perl.org/src/GBARR/IO-1.25/ChangeLog
-# <Apocalypse> Hmm yeah
-# <Apocalypse> * Make non-blocking mode work on Windows in IO::Socket::INET
-# <kmx> Apocalypse: exactly
-# <Apocalypse> Thanks for the tip! I'll go and add a TODO to the sslify code to investigate that :)
-
-
- # From IO::Handle POD
- # If an error occurs blocking will return undef and $! will be set.
- if ( ! $socket->blocking( 0 ) ) {
- die "Unable to set nonblocking mode on socket: $!";
- }
- } else {
- # Make the handle nonblocking, the POSIX way.
- if ( $^O ne 'MSWin32' ) {
- # Get the old flags
- my $flags = fcntl( $socket, F_GETFL, 0 ) or die "fcntl( $socket, F_GETFL, 0 ) fails: $!";
-
- # Okay, we patiently wait until the socket turns nonblocking mode
- until( fcntl( $socket, F_SETFL, $flags | O_NONBLOCK ) ) {
- # What was the error?
- if ( ! ( $! == EAGAIN or $! == EWOULDBLOCK ) ) {
- # Fatal error...
- die "fcntl( $socket, FSETFL, etc ) fails: $!";
- }
- }
- } else {
- # Darned MSWin32 way...
- # Do some ioctl magic here
- # 126 is FIONBIO ( some docs say 0x7F << 16 )
- my $flag = "1";
- ioctl( $socket, 0x80000000 | ( 4 << 16 ) | ( ord( 'f' ) << 8 ) | 126, $flag ) or die "ioctl( $socket, FIONBIO, $flag ) fails: $!";
- }
- }
-
- # All done!
- return $socket;
-}
-
# Okay, the main routine here!
sub Client_SSLify {
# Get the socket + version + options + ctx
@@ -112,8 +52,11 @@ sub Client_SSLify {
die "Did not get a defined socket";
}
- # Set non-blocking
- $socket = _NonBlocking( $socket );
+ # From IO::Handle POD
+ # If an error occurs blocking will return undef and $! will be set.
+ if ( ! defined $socket->blocking( 0 ) ) {
+ die "Unable to set nonblocking mode on socket: $!";
+ }
# Now, we create the new socket and bind it to our subclass of Net::SSLeay::Handle
my $newsock = gensym();
@@ -139,8 +82,11 @@ sub Server_SSLify {
die 'Please do SSLify_Options() first ( or pass in a $ctx object )';
}
- # Set non-blocking
- $socket = _NonBlocking( $socket );
+ # From IO::Handle POD
+ # If an error occurs blocking will return undef and $! will be set.
+ if ( ! defined $socket->blocking( 0 ) ) {
+ die "Unable to set nonblocking mode on socket: $!";
+ }
# Now, we create the new socket and bind it to our subclass of Net::SSLeay::Handle
my $newsock = gensym();
@@ -250,15 +196,9 @@ sub SSLify_GetSocket {
return tied( *$sock )->{'socket'};
}
-# End of module
1;
-__END__
-=for stopwords AnnoCPAN CPAN CPANTS Kwalitee RT SSL com diff github FreeBSD OpenSSL
-
-=head1 NAME
-
-POE::Component::SSLify - Makes using SSL in the world of POE easy!
+=pod
=head1 SYNOPSIS
@@ -291,7 +231,7 @@ POE::Component::SSLify - Makes using SSL in the world of POE easy!
# SERVER-side usage
- # !!! Make sure you have a public key + certificate generated via Net::SSLeay's makecert.pl
+ # !!! Make sure you have a public key + certificate
# excellent howto: http://www.akadia.com/services/ssh_test_certificate.html
# Import the module
@@ -323,10 +263,6 @@ POE::Component::SSLify - Makes using SSL in the world of POE easy!
# Use it as you wish...
# End of example
-=head1 ABSTRACT
-
- Makes SSL use in POE a breeze!
-
=head1 DESCRIPTION
This component represents the standard way to do SSL in POE.
@@ -366,10 +302,15 @@ possible function against SSLify, so use them carefully! If you have success, pl
=head3 Net::SSLeay::renegotiate
-This function has been tested ( it's in t/3_renegotiate.t ) but it doesn't work on FreeBSD! I tracked it down to this security advisory:
+This function has been tested ( it's in C<t/2_renegotiate.t> ) but it doesn't work on FreeBSD! I tracked it down to this security advisory:
L<http://security.freebsd.org/advisories/FreeBSD-SA-09:15.ssl.asc> which explains it in detail. The test will skip this function
if it detects that you're on a broken system. However, if you have the updated OpenSSL library that fixes this you can use it.
+=head3 In-Situ sslification
+
+You can have a normal plaintext socket, and convert it to SSL anytime. Just keep in mind that the client and the server must agree to sslify
+at the same time, or they will be waiting on each other forever! See C<t/3_insitu.t> for an example of how this works.
+
=head1 FUNCTIONS
=head2 Client_SSLify
@@ -496,73 +437,11 @@ if it detects that you're on a broken system. However, if you have the updated O
Stuffs all of the above functions in @EXPORT_OK so you have to request them directly
-=head1 SUPPORT
-
-You can find documentation for this module with the perldoc command.
-
- perldoc POE::Component::SSLify
-
-=head2 Websites
-
-=over 4
-
-=item * Search CPAN
-
-L<http://search.cpan.org/dist/POE-Component-SSLify>
-
-=item * AnnoCPAN: Annotated CPAN documentation
-
-L<http://annocpan.org/dist/POE-Component-SSLify>
-
-=item * CPAN Ratings
-
-L<http://cpanratings.perl.org/d/POE-Component-SSLify>
-
-=item * CPAN Forum
-
-L<http://cpanforum.com/dist/POE-Component-SSLify>
-
-=item * RT: CPAN's Request Tracker
-
-L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=POE-Component-SSLify>
-
-=item * CPANTS Kwalitee
-
-L<http://cpants.perl.org/dist/overview/POE-Component-SSLify>
-
-=item * CPAN Testers Results
-
-L<http://cpantesters.org/distro/P/POE-Component-SSLify.html>
-
-=item * CPAN Testers Matrix
-
-L<http://matrix.cpantesters.org/?dist=POE-Component-SSLify>
-
-=item * Git Source Code Repository
-
-This code is currently hosted on github.com under the account "apocalypse". Please feel free to browse it
-and pull from it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull
-from your repository :)
-
-L<http://github.com/apocalypse/perl-poe-sslify>
-
-=back
-
-=head2 Bugs
-
-Please report any bugs or feature requests to C<bug-poe-component-sslify at rt.cpan.org>, or through
-the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=POE-Component-SSLify>. I will be
-notified, and then you'll automatically be notified of progress on your bug as I make changes.
-
=head1 SEE ALSO
+POE
+Net::SSLeay
-L<POE>
-
-L<Net::SSLeay>
-
-=head1 AUTHOR
-
-Apocalypse E<lt>apocal@cpan.orgE<gt>
+=head1 ACKNOWLEDGEMENTS
Original code is entirely Rocco Caputo ( Creator of POE ) -> I simply
packaged up the code into something everyone could use and accepted the burden
@@ -576,13 +455,4 @@ Apocalypse E<lt>apocal@cpan.orgE<gt>
ASCENT also helped a lot with the nonblocking mode, without his hard work this
module would still be stuck in the stone age :)
-=head1 COPYRIGHT AND LICENSE
-
-Copyright 2010 by Apocalypse/Rocco Caputo/Dariusz Jackowski
-
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-The full text of the license can be found in the LICENSE file included with this module.
-
=cut
View
32 lib/POE/Component/SSLify/ClientHandle.pm
@@ -1,9 +1,6 @@
package POE::Component::SSLify::ClientHandle;
-use strict; use warnings;
-# Initialize our version
-use vars qw( $VERSION );
-$VERSION = '0.20';
+# ABSTRACT: Client-side handle for SSLify
# Import the SSL death routines
use Net::SSLeay qw( die_now die_if_ssl_error );
@@ -45,38 +42,15 @@ sub TIEHANDLE {
return $self;
}
-# End of module
1;
-__END__
-
-=head1 NAME
-
-POE::Component::SSLify::ClientHandle - client object for POE::Component::SSLify
-
-=head1 ABSTRACT
-
- See POE::Component::SSLify::ServerHandle
+=pod
=head1 DESCRIPTION
This is a subclass of ServerHandle to accomodate clients setting custom context objects.
=head1 SEE ALSO
-
-L<POE::Component::SSLify>
-
-L<POE::Component::SSLify::ServerHandle>
-
-=head1 AUTHOR
-
-Apocalypse E<lt>apocal@cpan.orgE<gt>
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright 2010 by Apocalypse
-
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
+POE::Component::SSLify::ServerHandle
=cut
View
31 lib/POE/Component/SSLify/ServerHandle.pm
@@ -1,9 +1,6 @@
package POE::Component::SSLify::ServerHandle;
-use strict; use warnings;
-# Initialize our version
-use vars qw( $VERSION );
-$VERSION = '0.20';
+# ABSTRACT: Server-side handle for SSLify
# Import the SSL death routines
use Net::SSLeay qw( die_now die_if_ssl_error );
@@ -157,18 +154,9 @@ sub PRINT {
die 'Not Implemented';
}
-# End of module
1;
-__END__
-
-=head1 NAME
-
-POE::Component::SSLify::ServerHandle - server object for POE::Component::SSLify
-
-=head1 ABSTRACT
-
- See POE::Component::SSLify
+=pod
=head1 DESCRIPTION
@@ -182,19 +170,4 @@ POE::Component::SSLify::ServerHandle - server object for POE::Component::SSLify
This subclass doesn't know what to do with PRINT/READLINE, as they usually are not used in POE::Wheel operations...
-=head1 SEE ALSO
-
-L<POE::Component::SSLify>
-
-=head1 AUTHOR
-
-Apocalypse E<lt>apocal@cpan.orgE<gt>
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright 2010 by Apocalypse
-
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
=cut
View
0  POE-Component-SSLify-0.01.tar.gz → releases/POE-Component-SSLify-0.01.tar.gz
File renamed without changes
View
0  POE-Component-SSLify-0.02.tar.gz → releases/POE-Component-SSLify-0.02.tar.gz
File renamed without changes
View
0  POE-Component-SSLify-0.03.tar.gz → releases/POE-Component-SSLify-0.03.tar.gz
File renamed without changes
View
0  POE-Component-SSLify-0.04.tar.gz → releases/POE-Component-SSLify-0.04.tar.gz
File renamed without changes
View
0  POE-Component-SSLify-0.05.tar.gz → releases/POE-Component-SSLify-0.05.tar.gz
File renamed without changes
View
0  POE-Component-SSLify-0.06.tar.gz → releases/POE-Component-SSLify-0.06.tar.gz
File renamed without changes
View
0  POE-Component-SSLify-0.07.tar.gz → releases/POE-Component-SSLify-0.07.tar.gz
File renamed without changes
View
0  POE-Component-SSLify-0.08.tar.gz → releases/POE-Component-SSLify-0.08.tar.gz
File renamed without changes
View
0  POE-Component-SSLify-0.09.tar.gz → releases/POE-Component-SSLify-0.09.tar.gz
File renamed without changes
View
0  POE-Component-SSLify-0.10.tar.gz → releases/POE-Component-SSLify-0.10.tar.gz
File renamed without changes
View
0  POE-Component-SSLify-0.11.tar.gz → releases/POE-Component-SSLify-0.11.tar.gz
File renamed without changes
View
0  POE-Component-SSLify-0.12.tar.gz → releases/POE-Component-SSLify-0.12.tar.gz
File renamed without changes
View
0  POE-Component-SSLify-0.13.tar.gz → releases/POE-Component-SSLify-0.13.tar.gz
File renamed without changes
View
0  POE-Component-SSLify-0.14.tar.gz → releases/POE-Component-SSLify-0.14.tar.gz
File renamed without changes
View
0  POE-Component-SSLify-0.15.tar.gz → releases/POE-Component-SSLify-0.15.tar.gz
File renamed without changes
View
0  POE-Component-SSLify-0.16.tar.gz → releases/POE-Component-SSLify-0.16.tar.gz
File renamed without changes
View
0  POE-Component-SSLify-0.17.tar.gz → releases/POE-Component-SSLify-0.17.tar.gz
File renamed without changes
View
0  POE-Component-SSLify-0.18.tar.gz → releases/POE-Component-SSLify-0.18.tar.gz
File renamed without changes
View
0  POE-Component-SSLify-0.19.tar.gz → releases/POE-Component-SSLify-0.19.tar.gz
File renamed without changes
View
0  POE-Component-SSLify-0.20.tar.gz → releases/POE-Component-SSLify-0.20.tar.gz
File renamed without changes
View
20 t/1_load.t
@@ -1,20 +0,0 @@
-#!/usr/bin/perl
-use strict; use warnings;
-
-my $numtests;
-BEGIN {
- $numtests = 3;
-
- eval "use Test::NoWarnings";
- if ( ! $@ ) {
- # increment by one
- $numtests++;
-
- }
-}
-
-use Test::More tests => $numtests;
-
-use_ok( 'POE::Component::SSLify::ServerHandle' );
-use_ok( 'POE::Component::SSLify::ClientHandle' );
-use_ok( 'POE::Component::SSLify' );
View
55 t/2_simple.t → t/1_simple.t
@@ -18,11 +18,10 @@ BEGIN {
use Test::More tests => $numtests;
-use POE;
+use POE 1.267;
use POE::Component::Client::TCP;
use POE::Component::Server::TCP;
-use POE::Component::SSLify qw/Client_SSLify Server_SSLify SSLify_Options SSLify_GetCipher SSLify_ContextCreate/;
-use POSIX qw/F_GETFL O_NONBLOCK/;
+use POE::Component::SSLify qw/Client_SSLify Server_SSLify SSLify_Options SSLify_GetCipher SSLify_ContextCreate SSLify_GetSocket/;
# TODO rewrite this to use Test::POE::Server::TCP and stuff :)
@@ -58,29 +57,25 @@ POE::Component::Server::TCP->new
ok(!$@, "SERVER: Server_SSLify $@");
ok(1, 'SERVER: SSLify_GetCipher: '. SSLify_GetCipher($socket));
- # MSWin32 doesn't have F_GETFL and friends
- if ( $^O eq 'MSWin32' ) {
- # We pray that IO::Handle is sane...
- ok( ! $_[ARG0]->blocking, 'SERVER: SSLified socket is non-blocking?');
- } else {
- my $flags = fcntl($_[ARG0], F_GETFL, 0);
- ok($flags & O_NONBLOCK, 'SERVER: SSLified socket is non-blocking?');
- }
+ # We pray that IO::Handle is sane...
+ ok( SSLify_GetSocket( $socket )->blocking == 0, 'SERVER: SSLified socket is non-blocking?');
return ($socket);
},
ClientInput => sub
{
- my ($kernel, $heap, $request) = @_[KERNEL, HEAP, ARG0];
+ my ($kernel, $heap, $line) = @_[KERNEL, HEAP, ARG0];
- ## At this point, connection MUST be encrypted.
- my $cipher = SSLify_GetCipher($heap->{client}->get_output_handle);
- ok($cipher ne '(NONE)', "SERVER: SSLify_GetCipher: $cipher");
+ if ( $line eq 'ping' ) {
+ ok(1, "SERVER: recv: $line");
+
+ ## At this point, connection MUST be encrypted.
+ my $cipher = SSLify_GetCipher($heap->{client}->get_output_handle);
+ ok($cipher ne '(NONE)', "SERVER: SSLify_GetCipher: $cipher");
- if ($request eq 'ping')
- {
- ok(1, "SERVER: recv: $request");
$heap->{client}->put("pong");
+ } else {
+ die "Unknown line from CLIENT: $line";
}
},
ClientError => sub
@@ -119,14 +114,8 @@ POE::Component::Client::TCP->new
ok(!$@, "CLIENT: Client_SSLify $@");
ok(1, 'CLIENT: SSLify_GetCipher: '. SSLify_GetCipher($socket));
- # MSWin32 doesn't have F_GETFL and friends
- if ( $^O eq 'MSWin32' ) {
- # We pray that IO::Handle is sane...
- ok( ! $_[ARG0]->blocking, 'CLIENT: SSLified socket is non-blocking?');
- } else {
- my $flags = fcntl($_[ARG0], F_GETFL, 0);
- ok($flags & O_NONBLOCK, 'CLIENT: SSLified socket is non-blocking?');
- }
+ # We pray that IO::Handle is sane...
+ ok( SSLify_GetSocket( $socket )->blocking == 0, 'CLIENT: SSLified socket is non-blocking?');
return ($socket);
},
@@ -134,14 +123,16 @@ POE::Component::Client::TCP->new
{
my ($kernel, $heap, $line) = @_[KERNEL, HEAP, ARG0];
- ## At this point, connection MUST be encrypted.
- my $cipher = SSLify_GetCipher($heap->{server}->get_output_handle);
- ok($cipher ne '(NONE)', "CLIENT: SSLify_GetCipher: $cipher");
-
- if ($line eq 'pong')
- {
+ if ($line eq 'pong') {
ok(1, "CLIENT: recv: $line");
+
+ ## At this point, connection MUST be encrypted.
+ my $cipher = SSLify_GetCipher($heap->{server}->get_output_handle);
+ ok($cipher ne '(NONE)', "CLIENT: SSLify_GetCipher: $cipher");
+
$kernel->yield('shutdown');
+ } else {
+ die "Unknown line from SERVER: $line";
}
},
ServerError => sub
View
25 t/3_renegotiate.t → t/2_renegotiate.t
@@ -22,12 +22,11 @@ BEGIN {
use Test::More tests => $numtests;
-use POE;
+use POE 1.267;
use POE::Component::Client::TCP;
use POE::Component::Server::TCP;
-use POE::Component::SSLify qw/Client_SSLify Server_SSLify SSLify_Options SSLify_GetCipher SSLify_ContextCreate/;
+use POE::Component::SSLify qw/Client_SSLify Server_SSLify SSLify_Options SSLify_GetCipher SSLify_ContextCreate SSLify_GetSocket/;
use Net::SSLeay qw/ERROR_WANT_READ ERROR_WANT_WRITE/;
-use POSIX qw/F_GETFL O_NONBLOCK/;
# TODO rewrite this to use Test::POE::Server::TCP and stuff :)
@@ -65,14 +64,8 @@ POE::Component::Server::TCP->new
ok(!$@, "SERVER: Server_SSLify $@");
ok(1, 'SERVER: SSLify_GetCipher: '. SSLify_GetCipher($socket));
- # MSWin32 doesn't have F_GETFL and friends
- if ( $^O eq 'MSWin32' ) {
- # We pray that IO::Handle is sane...
- ok( ! $_[ARG0]->blocking, 'SERVER: SSLified socket is non-blocking?');
- } else {
- my $flags = fcntl($_[ARG0], F_GETFL, 0);
- ok($flags & O_NONBLOCK, 'SERVER: SSLified socket is non-blocking?');
- }
+ # We pray that IO::Handle is sane...
+ ok( SSLify_GetSocket( $socket )->blocking == 0, 'SERVER: SSLified socket is non-blocking?');
return ($socket);
},
@@ -132,14 +125,8 @@ POE::Component::Client::TCP->new
ok(!$@, "CLIENT: Client_SSLify $@");
ok(1, 'CLIENT: SSLify_GetCipher: '. SSLify_GetCipher($socket));
- # MSWin32 doesn't have F_GETFL and friends
- if ( $^O eq 'MSWin32' ) {
- # We pray that IO::Handle is sane...
- ok( ! $_[ARG0]->blocking, 'CLIENT: SSLified socket is non-blocking?');
- } else {
- my $flags = fcntl($_[ARG0], F_GETFL, 0);
- ok($flags & O_NONBLOCK, 'CLIENT: SSLified socket is non-blocking?');
- }
+ # We pray that IO::Handle is sane...
+ ok( SSLify_GetSocket( $socket )->blocking == 0, 'CLIENT: SSLified socket is non-blocking?');
return ($socket);
},
View
185 t/3_insitu.t
@@ -0,0 +1,185 @@
+#!/usr/bin/perl
+
+# Thanks to ASCENT for this test!
+
+use strict; use warnings;
+
+my $numtests;
+BEGIN {
+ $numtests = 18;
+
+ eval "use Test::NoWarnings";
+ if ( ! $@ ) {
+ # increment by one
+ $numtests++;
+
+ }
+}
+
+use Test::More tests => $numtests;
+
+use POE 1.267;
+use POE::Component::Client::TCP;
+use POE::Component::Server::TCP;
+use POE::Component::SSLify qw/Client_SSLify Server_SSLify SSLify_Options SSLify_GetCipher SSLify_ContextCreate SSLify_GetSocket/;
+
+# TODO rewrite this to use Test::POE::Server::TCP and stuff :)
+
+my $port;
+
+POE::Component::Server::TCP->new
+(
+ Alias => 'myserver',
+ Address => '127.0.0.1',
+ Port => 0,
+
+ Started => sub
+ {
+ use Socket qw/sockaddr_in/;
+ $port = (sockaddr_in($_[HEAP]->{listener}->getsockname))[0];
+ },
+ ClientConnected => sub
+ {
+ ok(1, 'SERVER: accepted');
+ },
+ ClientDisconnected => sub
+ {
+ ok(1, 'SERVER: client disconnected');
+ $_[KERNEL]->post(myserver => 'shutdown');
+ },
+ ClientInput => sub
+ {
+ my ($kernel, $heap, $line) = @_[KERNEL, HEAP, ARG0];
+
+ if ( $line eq 'plaintext_ping' ) {
+ ok(1, "SERVER: recv: $line");
+ $heap->{client}->put('plaintext_pong');
+ $heap->{client}->flush; # make sure we sent the pong
+
+ # sslify it in-situ!
+ eval { SSLify_Options('mylib/example.key', 'mylib/example.crt', 'sslv3') };
+ eval { SSLify_Options('../mylib/example.key', '../mylib/example.crt', 'sslv3') } if ($@);
+ ok(!$@, "SERVER: SSLify_Options $@");
+ my $socket = eval { Server_SSLify($heap->{client}->get_output_handle) };
+ ok(!$@, "SERVER: Server_SSLify $@");
+ ok(1, 'SERVER: SSLify_GetCipher: '. SSLify_GetCipher($socket));
+
+ # We pray that IO::Handle is sane...
+ ok( SSLify_GetSocket( $socket )->blocking == 0, 'SERVER: SSLified socket is non-blocking?');
+
+ # TODO evil code here, ha!
+ # Should I ask rcaputo to add a $rw->replace_handle($socket) method?
+ # if you don't do the undef and just replace it - you'll get a bad file descriptor error from POE!
+ # <fh> select error: Bad file descriptor (hits=-1)
+ undef $heap->{client};
+ $heap->{client} = POE::Wheel::ReadWrite->new(
+ Handle => $socket,
+ InputEvent => 'tcp_server_got_input',
+ ErrorEvent => 'tcp_server_got_error',
+ FlushedEvent => 'tcp_server_got_flush',
+ );
+ } elsif ( $line eq 'ssl_ping' ) {
+ ok(1, "SERVER: recv: $line");
+
+ ## At this point, connection MUST be encrypted.
+ my $cipher = SSLify_GetCipher($heap->{client}->get_output_handle);
+ ok($cipher ne '(NONE)', "SERVER: SSLify_GetCipher: $cipher");
+
+ $heap->{client}->put('ssl_pong');
+ } else {
+ die "Unknown line from CLIENT: $line";
+ }
+ },
+ ClientError => sub
+ {
+ # Thanks to H. Merijn Brand for spotting this FAIL in 5.12.0!
+ # The default PoCo::Server::TCP handler will throw a warning, which causes Test::NoWarnings to FAIL :(
+ my ($syscall, $errno, $error) = @_[ ARG0..ARG2 ];
+
+ # TODO are there other "errors" that is harmless?
+ $error = "Normal disconnection" unless $error;
+ my $msg = "Got SERVER $syscall error $errno: $error";
+ unless ( $syscall eq 'read' and $errno == 0 ) {
+ fail( $msg );
+ } else {
+ diag( $msg ) if $ENV{TEST_VERBOSE};
+ }
+ },
+);
+
+POE::Component::Client::TCP->new
+(
+ Alias => 'myclient',
+ RemoteAddress => '127.0.0.1',
+ RemotePort => $port,
+ Connected => sub
+ {
+ ok(1, 'CLIENT: connected');
+
+ $_[HEAP]->{server}->put("plaintext_ping");
+ },
+ ServerInput => sub
+ {
+ my ($kernel, $heap, $line) = @_[KERNEL, HEAP, ARG0];
+
+ if ( $line eq 'plaintext_pong' ) {
+ ok(1, "CLIENT: recv: $line");
+
+ # sslify it in-situ!
+ my $ctx = eval { SSLify_ContextCreate(undef, undef, 'sslv3') };
+ ok(!$@, "CLIENT: SSLify_ContextCreate $@");
+ my $socket = eval { Client_SSLify($heap->{server}->get_output_handle, undef, undef, $ctx) };
+ ok(!$@, "CLIENT: Client_SSLify $@");
+ ok(1, 'CLIENT: SSLify_GetCipher: '. SSLify_GetCipher($socket));
+
+ # We pray that IO::Handle is sane...
+ ok( SSLify_GetSocket( $socket )->blocking == 0, 'CLIENT: SSLified socket is non-blocking?');
+
+ # TODO evil code here, ha!
+ # Should I ask rcaputo to add a $rw->replace_handle($socket) method?
+ # if you don't do the undef and just replace it - you'll get a bad file descriptor error from POE!
+ # <fh> select error: Bad file descriptor (hits=-1)
+ undef $heap->{server};
+ $heap->{server} = POE::Wheel::ReadWrite->new(
+ Handle => $socket,
+ InputEvent => 'got_server_input',
+ ErrorEvent => 'got_server_error',
+ FlushedEvent => 'got_server_flush',
+ );
+
+ # Send the ssl ping!
+ $heap->{server}->put('ssl_ping');
+ } elsif ( $line eq 'ssl_pong' ) {
+ ok(1, "CLIENT: recv: $line");
+
+ ## At this point, connection MUST be encrypted.
+ my $cipher = SSLify_GetCipher($heap->{server}->get_output_handle);
+ ok($cipher ne '(NONE)', "CLIENT: SSLify_GetCipher: $cipher");
+
+ $kernel->yield('shutdown');
+ } else {
+ die "Unknown line from SERVER: $line";
+ }
+ },
+ ServerError => sub
+ {
+ # Thanks to H. Merijn Brand for spotting this FAIL in 5.12.0!
+ # The default PoCo::Client::TCP handler will throw a warning, which causes Test::NoWarnings to FAIL :(
+ my ($syscall, $errno, $error) = @_[ ARG0..ARG2 ];
+
+ # TODO are there other "errors" that is harmless?
+ $error = "Normal disconnection" unless $error;
+ my $msg = "Got CLIENT $syscall error $errno: $error";
+ unless ( $syscall eq 'read' and $errno == 0 ) {
+ fail( $msg );
+ } else {
+ diag( $msg ) if $ENV{TEST_VERBOSE};
+ }
+ },
+);
+
+$poe_kernel->run();
+
+pass( 'shut down sanely' );
+
+exit 0;
View
12 t/apocalypse.t
@@ -1,12 +0,0 @@
-#!/usr/bin/perl
-use strict; use warnings;
-
-use Test::More;
-eval "use Test::Apocalypse 0.10";
-if ( $@ ) {
- plan skip_all => 'Test::Apocalypse required for validating the distribution';
-} else {
- # lousy hack for kwalitee
- require Test::NoWarnings; require Test::Pod; require Test::Pod::Coverage;
- is_apocalypse_here();
-}
Please sign in to comment.
Something went wrong with that request. Please try again.