From c93b33275cba839c7e4b8ee7e142f4db8f5f4c12 Mon Sep 17 00:00:00 2001 From: "Brian L. Troutwine" Date: Sat, 11 Feb 2012 18:51:41 -0500 Subject: [PATCH] Traut is now v1.0.0, now with SSL capability. Traut is now able to perform SSL connections to an AMQP daemon, passing client certificates back as needed. There's a slight UI change to accommodate this, but otherwise little user-facing has changed. Example traut.conf is updated to document SSL capability. Signed-off-by: Brian L. Troutwine --- etc/traut.conf | 6 ++++-- lib/traut.rb | 3 ++- lib/traut/application.rb | 15 +++++++++++++-- lib/traut/version.rb | 2 +- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/etc/traut.conf b/etc/traut.conf index afa9ba7..3148071 100644 --- a/etc/traut.conf +++ b/etc/traut.conf @@ -1,11 +1,13 @@ amqp: host: localhost - port: 5672 + port: 5671 vhost: '/' username: 'guest' password: 'guest' exchange: 'traut' - queue: '' + ssl: + private_key: /etc/rabbitmq/ca/client/key.pem + cert_chain: /etc/rabbitmq/ca/client/cert.pem debug: true logdir: './logs/' diff --git a/lib/traut.rb b/lib/traut.rb index a3f9109..59f2536 100644 --- a/lib/traut.rb +++ b/lib/traut.rb @@ -14,7 +14,8 @@ def self.defaults { 'config' => './traut.conf', 'logdir' => './logs/', - 'debug' => true + 'debug' => true, + 'ssl' => {} } end end diff --git a/lib/traut/application.rb b/lib/traut/application.rb index adf50bc..a899813 100644 --- a/lib/traut/application.rb +++ b/lib/traut/application.rb @@ -15,11 +15,22 @@ def run @logger = Logger.new File.join( File.expand_path(@options['logdir']), 'traut.log') @logger.level = boolean(@options['debug']) ? Logger::DEBUG : Logger::INFO - ## NOTE: Have to start AMQP connection out here. + ## We start the AMQP connection out here, rather than in Server, to + ## isolate that code from its specific duties and so that we do not have + ## to pass extranious configuration details into it. amqp = @options['amqp'] AMQP.connect(:host => amqp['host'], :port => amqp['port'], :vhost => amqp['vhost'], - :username => amqp['username'], :password => amqp['password']) do |connection| + :username => amqp['username'], :password => amqp['password'], :ssl => { + :cert_chain_file => amqp['ssl']['cert_chain'], + :private_key_file => amqp['ssl']['private_key'] + }, + :on_tcp_connection_failure => Proc.new { |settings| + puts "TCP Connection failure; details:\n\n#{settings.inspect}\n\n"; exit 1 + }, + :on_possible_authentication_failure => Proc.new { |settings| + puts "Authentication failure, I'm afraid:\n\n#{settings.inspect}\n\n"; exit 1 + }) do |connection| @logger.info "Traut #{Traut::VERSION} started" channel = AMQP::Channel.new(connection) exchange = channel.topic(amqp['exchange'] || 'traut') diff --git a/lib/traut/version.rb b/lib/traut/version.rb index 5553d3c..52d799d 100644 --- a/lib/traut/version.rb +++ b/lib/traut/version.rb @@ -1,3 +1,3 @@ module Traut - VERSION = "0.2.4" + VERSION = "1.0.0" end