1POE::Component::SSLify(U3spemr)Contributed Perl DocumentPaOtEi:o:nComponent::SSLify(3pm)
2
3
4

NAME

6       POE::Component::SSLify - Makes using SSL in the world of POE easy!
7

VERSION

9         This document describes v1.012 of POE::Component::SSLify - released November 14, 2014 as part of POE-Component-SSLify.
10

SYNOPSIS

12               # look at the DESCRIPTION for client and server example code
13

DESCRIPTION

15       This component is a method to simplify the SSLification of a socket
16       before it is passed to a POE::Wheel::ReadWrite wheel in your
17       application.
18
19   Client usage
20               # Import the module
21               use POE::Component::SSLify qw( Client_SSLify );
22
23               # Create a normal SocketFactory wheel and connect to a SSL-enabled server
24               my $factory = POE::Wheel::SocketFactory->new;
25
26               # Time passes, SocketFactory gives you a socket when it connects in SuccessEvent
27               # Convert the socket into a SSL socket POE can communicate with
28               my $socket = shift;
29               eval { $socket = Client_SSLify( $socket ) };
30               if ( $@ ) {
31                       # Unable to SSLify it...
32               }
33
34               # Now, hand it off to ReadWrite
35               my $rw = POE::Wheel::ReadWrite->new(
36                       Handle  =>      $socket,
37                       # other options as usual
38               );
39
40   Server usage
41               # !!! Make sure you have a public key + certificate
42               # excellent howto: http://www.akadia.com/services/ssh_test_certificate.html
43
44               # Import the module
45               use POE::Component::SSLify qw( Server_SSLify SSLify_Options );
46
47               # Set the key + certificate file
48               eval { SSLify_Options( 'server.key', 'server.crt' ) };
49               if ( $@ ) {
50                       # Unable to load key or certificate file...
51               }
52
53               # Create a normal SocketFactory wheel to listen for connections
54               my $factory = POE::Wheel::SocketFactory->new;
55
56               # Time passes, SocketFactory gives you a socket when it gets a connection in SuccessEvent
57               # Convert the socket into a SSL socket POE can communicate with
58               my $socket = shift;
59               eval { $socket = Server_SSLify( $socket ) };
60               if ( $@ ) {
61                       # Unable to SSLify it...
62               }
63
64               # Now, hand it off to ReadWrite
65               my $rw = POE::Wheel::ReadWrite->new(
66                       Handle  =>      $socket,
67                       # other options as usual
68               );
69

FUNCTIONS

71   Client_SSLify
72       This function sslifies a client-side socket. You can pass several
73       options to it:
74
75               my $socket = shift;
76               $socket = Client_SSLify( $socket, $version, $options, $ctx, $callback );
77                       $socket is the non-ssl socket you got from somewhere ( required )
78                       $version is the SSL version you want to use
79                       $options is the SSL options you want to use
80                       $ctx is the custom SSL context you want to use
81                       $callback is the callback hook on success/failure of sslification
82
83                       # This is an example of the callback and you should pass it as Client_SSLify( $socket, ... , \&callback );
84                       sub callback {
85                               my( $socket, $status, $errval ) = @_;
86                               # $socket is the original sslified socket in case you need to play with it
87                               # $status is either 1 or 0; with 1 signifying success and 0 failure
88                               # $errval will be defined if $status == 0; it's the numeric SSL er