ruby-amqp/bunny — pull request #31 by tobert (2012-01-03 08:40:50+00:00)
Title: Pass through ssl_context to SSLSocket.new

I'm messing around with some SSL options that are not currently
supported by Bunny, like client certificate authentication. The simplest
way I found to get started is this commit, which lets me create an
OpenSSL context object ahead of time, then pass it through to Bunny's
socket calls.

In the long run, this might be the best play. The alternative is
supporting all of the fiddly little ways people use SSL and, especially
fiddly, SSL authentication.

If you don't like this patch, no biggie. I just thought I'd throw it out there in case you're interested. If I find a better way down the road, I'll send it along.

Example:

require 'bunny'
require 'openssl'

ssl_context = OpenSSL::SSL::SSLContext.new()

ssl_context.cert = OpenSSL::X509::Certificate.new(File.open("client-cert.pem"))
ssl_context.key = OpenSSL::PKey::RSA.new(File.open("client-key.pem"))

b = Bunny.new(:logging => true, :ssl => true, :port => 8140, :ssl_context => ssl_context, :ssl_verify => true)