Subject: | SSL support in POE::Component::Client::TCP |
That would be nice to have SSL support in POE::Component::Client::TCP. I
have attached example patch.
Subject: | pocotcp-ssl.patch |
--- /usr/local/share/perl/5.8.8/POE/Component/Client/TCP.pm 2007-01-01 09:38:55.000000000 +0100
+++ TCPSSL.pm 2008-06-11 16:41:35.000000000 +0200
@@ -46,6 +46,9 @@
my $domain = delete $param{Domain};
my $bind_address = delete $param{BindAddress};
my $bind_port = delete $param{BindPort};
+ my $ssl_enable = delete $param{SSL};
+ my $ssl_private = delete $param{SSLPrivate};
+ my $ssl_certificate = delete $param{SSLCertificate};
my $ctimeout = delete $param{ConnectTimeout};
my $args = delete $param{Args};
my $session_type = delete $param{SessionType};
@@ -194,6 +197,20 @@
got_connect_success => sub {
my ($kernel, $heap, $socket) = @_[KERNEL, HEAP, ARG0];
+ if ($ssl_enable) {
+ eval {
+ require POE::Component::SSLify;
+ import POE::Component::SSLify qw/SSLify_ContextCreate Client_SSLify/;
+ my $ctx = undef;
+ $ctx = SSLify_ContextCreate($ssl_private, $ssl_certificate) if (defined $ssl_private && defined $ssl_certificate);
+ $socket = Client_SSLify($socket, undef, undef, $ctx);
+ };
+ if ($@) {
+ $kernel->yield('got_connect_error', 'SSLify', 0, $@);
+ return;
+ }
+ }
+
$kernel->alarm_remove( delete $heap->{ctimeout_id} )
if exists $heap->{ctimeout_id};
@@ -372,6 +389,10 @@
Alias => $session_alias # Optional.
ConnectTimeout => 5, # Seconds; optional.
+ SSL => 1, # Optional.
+ SSLPrivate => '/path/to/file.pem', # Optional.
+ SSLCertificate => '/path/to/file.pem', # Optional.
+
SessionType => "POE::Session::Abc", # Optional.
SessionParams => [ options => { debug => 1 } ], # Optional.
@@ -661,6 +682,24 @@
The ServerInput function will stop being called when $heap->{shutdown}
is true.
+=item SSL
+
+Positive value will enable SSL connection.
+
+=item SSLCertificate
+
+Filename which contains a PEM encoded x509 certificate.
+
+This option is ONLY needed if server request and verify the client's
+x509 certificate.
+
+=item SSLPrivate
+
+Filename which contains a PEM encoded private key.
+
+This option is ONLY needed if server request and verify the client's
+x509 certificate.
+
=item Started
Started is an optional callback. It is called after Client::TCP is