Posted on 2009-05-29 07:23:43-07 by aivanise in response to 4013
Re: Net-Stomp support SSL Socket
Hi, I needed this too, so here is a patch against Stomp.pm to use IO::Socket::SSL I'm going to try to get it to the main distribution
--- /usr/lib/perl5/site_perl/5.8.8/Net/Stomp.pm.orig 2009-05-27 18:05:58.000000000 +0200 +++ /usr/lib/perl5/site_perl/5.8.8/Net/Stomp.pm 2009-05-29 09:46:57.000000000 +0200 @@ -2,20 +2,33 @@ package Net::Stomp; use strict; use warnings; use IO::Socket::INET; +use IO::Socket::SSL; use IO::Select; use Net::Stomp::Frame; use base 'Class::Accessor::Fast'; -__PACKAGE__->mk_accessors(qw(hostname port select socket)); +__PACKAGE__->mk_accessors(qw(hostname port select socket ssl)); our $VERSION = '0.34'; sub new { my $class = shift; my $self = $class->SUPER::new(@_); - my $socket = IO::Socket::INET->new( + my ($socket); + my %sockopts = ( PeerAddr => $self->hostname, + PeerPort => $self->port, + Proto => 'tcp' ); + + if ($self->ssl) { + %sockopts = ( %sockopts, %{$self->ssl} ); + $socket = IO::Socket::SSL->new( + %sockopts + ); + } else { + $socket = IO::Socket::INET->new( PeerAddr => $self->hostname, PeerPort => $self->port, Proto => 'tcp' - ); + ); + } die "Error connecting to " . $self->hostname . ':' . $self->port . ": $!" unless $socket; binmode($socket); @@ -169,6 +182,12 @@ a port: my $stomp = Net::Stomp->new( { hostname => 'localhost', port => '61613' } ); +If you want to use SSL, pass in a hash named ssl with optional extra options for +SSL (see IO::Socket::SSL for all possible options). + + my $stomp = Net::Stomp->new( { hostname => 'localhost', port => '61612', + ssl => { SSL_cipher_list => 'ALL:!EXPORT' } } ); + =head2 connect This connects to the Stomp server. You must pass in a login and
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.