FUNCTIONS

Client_SSLify

This function sslifies a client-side socket. You can pass several options to it:

my $socket = shift;
$socket = Client_SSLify( $socket, $version, $options, $ctx, $callback );
$socket is the non-ssl socket you got from somewhere ( required )
$version is the SSL version you want to use
$options is the SSL options you want to use
$ctx is the custom SSL context you want to use
$callback is the callback hook on success/failure of sslification
# This is an example of the callback and you should pass it as Client_SSLify( $socket, ... , \&callback );
sub callback {
my( $socket, $status, $errval ) = @_;
# $socket is the original sslified socket in case you need to play with it
# $status is either 1 or 0; with 1 signifying success and 0 failure
# $errval will be defined if $status == 0; it's the numeric SSL error code
# check http://www.openssl.org/docs/ssl/SSL_get_error.html for the possible error values ( and import them from Net::SSLeay! )
# The return value from the callback is discarded
}

If $ctx is defined, SSLify will ignore $version and $options. Otherwise, it will be created from the $version and $options parameters. If all of them are undefined, it will follow the defaults in "SSLify_ContextCreate".

BEWARE: If you passed in a CTX, SSLify will do Net::SSLeay::CTX_free( $ctx ) when the socket is destroyed. This means you cannot reuse contexts!

NOTE: The way to have a client socket with proper certificates set up is:

SSLify_Options

Call this function to initialize the global server-side context object. This will be the default context whenever you call "Server_SSLify" without passing a custom context to it.

SSLify_Options( $key, $cert, $version, $options );
$key is the certificate key file ( required )
$cert is the certificate file ( required )
$version is the SSL version to use
$options is the SSL options to use

SSLify_GetCTX

Returns the actual Net::SSLeay context object in case you wanted to play with it :)

If passed in a socket, it will return that socket's $ctx instead of the global.

my $ctx = SSLify_GetCTX(); # get the one set via SSLify_Options
my $ctx = SSLify_GetCTX( $sslified_sock ); # get the one in the object

SSLify_GetCipher

Returns the cipher used by the SSLified socket

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.

NOTES

Socket methods doesn't work

The new socket this module gives you actually is tied socket magic, so you cannot do stuff like getpeername() or getsockname(). The only way to do it is to use "SSLify_GetSocket" and then operate on the socket it returns.

Dying everywhere...

This module will die() if Net::SSLeay could not be loaded or it is not the version we want. So, it is recommended that you check for errors and not use SSL, like so:

$IGNORE_SSL_ERRORS

As of SSLify v1.003 you can override this variable to temporarily ignore some SSL errors. This is useful if you are doing crazy things with the underlying Net::SSLeay stuff and don't want to die. However, it won't ignore all errors as some is still considered fatal. Here's an example:

OpenSSL functions

Theoretically you can do anything that Net::SSLeay exports from the OpenSSL libs on the socket. However, I have not tested every possible function against SSLify, so use them carefully!

Net::SSLeay::renegotiate

This function has been tested ( it's in t/2_renegotiate_client.t ) but it doesn't work on FreeBSD! I tracked it down to this security advisory: 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.

NOTE: Calling this means the callback function you passed in "Client_SSLify" or "Server_SSLify" will not fire! If you need this please let me know and we can come up with a way to make it work.

Upgrading a non-ssl socket to SSL

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 t/3_upgrade.t for an example of how this works.

Downgrading a SSL socket to non-ssl

As of now this is unsupported. If you need this feature please let us know and we'll work on it together!

MSWin32 is not supported

This module doesn't work on MSWin32 platforms at all ( XP, Vista, 7, etc ) because of some weird underlying fd issues. Since I'm not a windows developer, I'm unable to fix this. However, it seems like Cygwin on MSWin32 works just fine! Please help me fix this if you can, thanks!

LOAD_SSL_ENGINES

OpenSSL supports loading ENGINEs to accelerate the crypto algorithms. SSLify v1.004 automatically loaded the engines, but there was some problems on certain platforms that caused coredumps. A big shout-out to BinGOs and CPANTesters for catching this! It's now disabled in v1.007 and you would need to explicitly enable it.

Email

You can email the author of this module at APOCAL at cpan.org asking for help with any problems you have.

Internet Relay Chat

You can get live help by using IRC ( Internet Relay Chat ). If you don't know what IRC is, please read this excellent guide: http://en.wikipedia.org/wiki/Internet_Relay_Chat. Please be courteous and patient when talking to us, as we might be busy or sleeping! You can join those networks/channels and get help:

irc.perl.org

You can connect to the server at 'irc.perl.org' and join this channel: #perl-help then talk to this person for help: Apocalypse.

irc.freenode.net

You can connect to the server at 'irc.freenode.net' and join this channel: #perl then talk to this person for help: Apocal.

irc.efnet.org

You can connect to the server at 'irc.efnet.org' and join this channel: #perl then talk to this person for help: Ap0cal.

Source Code

The code is open to the world, and available for you to hack on. Please feel free to browse it and play with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull from your repository :)

AUTHOR

Apocalypse <APOCAL@cpan.org>

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
of maintaining it :)
From the PoCo::Client::HTTP code =]
# This code should probably become a POE::Kernel method,
# seeing as it's rather baroque and potentially useful in a number
# of places.

ASCENT also helped a lot with the nonblocking mode, without his hard work this module would still be stuck in the stone age :)

A lot of people helped add various features/functions - please look at the changelog for more detail.

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Apocalypse.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

The full text of the license can be found in the LICENSE file included with this distribution.

DISCLAIMER OF WARRANTY

THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

Module Install Instructions

To install POE::Component::SSLify, simply copy and paste either of the commands in to your terminal

As a valued partner and proud supporter of MetaCPAN, StickerYou is
happy to offer a 10% discount on all Custom Stickers,
Business Labels, Roll Labels,
Vinyl Lettering or Custom Decals. StickerYou.com
is your one-stop shop to make your business stick.
Use code METACPAN10 at checkout to apply your discount.