Using TLS (SSL) with Ruby amqp gem and RabbitMQ

About this guide

This guide covers connection to RabbitMQ nodes using TLS (also known as
SSL) and related issues. This guide does not explain basic TLS concepts.
For that, refer to resources like Introduction to
SSL or Wikipedia
page on TLS.

Covered versions

This guide covers Ruby amqp gem 1.7.0 and later versions.

RabbitMQ Version Requirements

RabbitMQ has supported TLS since version 1.7.0. Minimum requirements are

Erlang R13B

Erlang SSL application 3.10

The recommended distribution is R14B (SSL 4.0.1) or later. This should
be considered the minimum configuration for Java and Erlang clients due
to an incorrect RC4 implementation in earlier versions of Erlang.

Pre-requisites

RabbitMQ needs to be configured to use TLS. Just like Web
servers, TLS connections are usually accepted on a separate port (5671).
rabbitmq.com TLS page describes how
to configure RabbitMQ to use TLS, how to generate certificates for
development and so on.

Connecting to RabbitMQ using TLS

To instruct Ruby amqp gem to use TLS for connection, pass :ssl option
that specifies certificate chain file path as well as private key file
path: