[rabbitmq-discuss] Perl SSL support for Net::RabbitMQ

Julio Polo julio at hawaii.edu
Tue May 29 22:21:47 BST 2012


If you are willing to use AnyEvent::RabbitMQ (chosen because it
required the least amount of additional software), I have a simple
patch to version 1.05 to make it work with SSL:

/usr/local/lib/site_perl/5.8.x/AnyEvent# diff RabbitMQ.pm.bak RabbitMQ.pm
95c95
<             $self->{_handle} = AnyEvent::Handle->new(
---
>             my %handle_args = (
113a114,117
>             if ($args{tls}) {
>                 $handle_args{tls} = 'connect';
>             }
>             $self->{_handle} = AnyEvent::Handle->new(%handle_args);

and you would simply add tls => 1 to the connection settings.
Hopefully this snippet of code is self-explanatory:

    my %basic_settings =
    (
        host       => $conf->{$CONF_host},
        port       => $conf->{$CONF_port},
        user       => $conf->{$CONF_user},
        pass       => $conf->{$CONF_pass},
        vhost      => $conf->{$CONF_vhost},
        timeout    => $conf->{$CONF_timeout},
    );

    # the tls option requires this patch to AnyEvent::RabbitMQ
=pod
95c95
<             $self->{_handle} = AnyEvent::Handle->new(
---
>             my %handle_args = (
113a114,117
>             if ($args{tls}) {
>                 $handle_args{tls} = 'connect';
>             }
>             $self->{_handle} = AnyEvent::Handle->new(%handle_args);
=cut
    if ($conf->{$CONF_secure})
    {
        $basic_settings{'tls'} = 1;  # this gets translated to connect
by above patch
    }

    my $cv = AnyEvent->condvar;

    my $ar;
    $ar = AnyEvent::RabbitMQ->new->load_xml_spec()->connect
    (
        %basic_settings,

        on_success => sub
        {
            $ar->open_channel
            (
                on_success => sub
                {
                    log_this( join(' ', 'RabbitMQ
open_channel->on_success: ', Dumper(@_)) ) if $debug;
                    shift->declare_exchange
                    (
                        exchange   => $exchange_name,
                        type       => 'topic',
                        passive    => $exchange_passive,
                        durable     => 1,
                        auto_delete => 0,
#                       internal    => 0,
                        on_success => sub
                        {
                            $cv->send("Declared exchange $exchange_name");
                        },
                        on_failure => $cv,
                    );
                },

                on_failure => $cv,

                on_close   => sub
                {
                    croak join(' ', 'RabbitMQ open_channel->on_close:
', Dumper(@_));
                }

            ); # open_channel

        }, # on_success

        on_failure      => $cv,

        on_read_failure => sub
        {
            croak join(' ', 'RabbitMQ connect->on_read_failure: ', Dumper(@_));
        },

        on_close        => sub
        {
            croak join(' ', 'RabbitMQ connect->on_close: ', Dumper(@_));
        },
    );

    $cv->recv;

    # return the channel for this connection
    my $channel = $ar->channels->{1}
        or croak "No channel in _connect\n";

We were planning to publish some of this code.  I can make it
available sooner if anyone is interested.

Julio Polo
Identity and Access Management
Information Technology Services
University of Hawaii


On Thu, May 24, 2012 at 4:15 PM, xtrm <xtrm2008 at live.com> wrote:
>
> So what is everyone doing in regards to SSL support?  Is everyone using
> either .NET or Java for their implementations?
>
> Thanks again for the help
>
>
>
> Alan Antonuk wrote:
>>
>> I believe (someone correct me if I'm wrong) Net::RabbitMQ is just a
>> wrapper
>> around the rabbitmq-c library, which does not support SSL as of yet, so
>> Net::RabbitMQ probably doesn't support SSL yet.
>>
>> There is currently an effort underway to add SSL support to rabbitmq-c,
>> but
>> it is not complete yet.
>>
>> -Alan
>>
>> On Thu, May 24, 2012 at 9:36 AM, xtrm <xtrm2008 at live.com> wrote:
>>
>>>
>>> Hello all,
>>>
>>> New to RabbitMQ and hoping someone on the forum has been through this
>>> before. I am trying to implement SSL client authentication to use with on
>>> all our clients.  I am unable to find any documentation on how to go
>>> about
>>> doing this.  I was able to find two examples in .NET and Java on the
>>> rabbitMQ SSL support website, but no mention on how to implement using
>>> Perl.
>>> Has anyone gotten this working?  If so how did you guys go about
>>> implementing SSL support?
>>>
>>> I currently have my clients publishing successfully using the non SSL
>>> port
>>> using Net::RabbitMQ module.
>>>
>>> Thanks for the help in advance.
>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Perl-SSL-support-for-Net%3A%3ARabbitMQ-tp33901964p33901964.html
>>> Sent from the RabbitMQ mailing list archive at Nabble.com.
>>>
>>> _______________________________________________
>>> rabbitmq-discuss mailing list
>>> rabbitmq-discuss at lists.rabbitmq.com
>>> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>>>
>>
>> _______________________________________________
>> rabbitmq-discuss mailing list
>> rabbitmq-discuss at lists.rabbitmq.com
>> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>>
>>
>
> --
> View this message in context: http://old.nabble.com/Perl-SSL-support-for-Net%3A%3ARabbitMQ-tp33901964p33905637.html
> Sent from the RabbitMQ mailing list archive at Nabble.com.
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss


More information about the rabbitmq-discuss mailing list