Sha256: b76197f6e1577be8bd0714a702620f628ba30c4b32662cb864cfbac837e295bc

Contents?: true

Size: 1.42 KB

Versions: 3

Compression:

Stored size: 1.42 KB

Contents

# -*- encoding: utf-8 -*-

#
# Reference: https://github.com/stompgem/stomp/wiki/extended-ssl-overview
#
require "rubygems"
require "stomp"
#
# == SSL Use Case 2 - server does *not* authenticate client, client *does* authenticate server
#
# Subcase 2.A - Message broker configuration does *not* require client authentication
#
# - Expect connection success
# - Expect a verify result of 0 becuase the client did authenticate the
#   server's certificate.
#
# Subcase 2.B - Message broker configuration *does* require client authentication
#
# - Expect connection failure (broker must be sent a valid client certificate)
#
class ExampleSSL2
  # Initialize.
  def initialize
  end
  # Run example.
  def run
    ts_flist = []

    # Change the following to the location of the server's CA signed certificate.
    ts_flist << "/home/gmallard/sslwork/2013/TestCA.crt"

    ssl_opts = Stomp::SSLParams.new(:ts_files => ts_flist.join(","), 
      :fsck => true)
    #
    hash = { :hosts => [
        {:login => 'guest', :passcode => 'guest', :host => 'localhost', :port => 61612, :ssl => ssl_opts},
      ],
      :reliable => false, # YMMV, to test this in a sane manner
    }
    #
    puts "Connect starts, SSL Use Case 2"
    c = Stomp::Connection.new(hash)
    puts "Connect completed"
    puts "SSL Verify Result: #{ssl_opts.verify_result}"
    # puts "SSL Peer Certificate:\n#{ssl_opts.peer_cert}"
    c.disconnect
  end
end
#
e = ExampleSSL2.new
e.run

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stomp-1.4.0 examples/ssl_uc2.rb
stomp-1.3.5 examples/ssl_uc2.rb
stomp-1.3.4 examples/ssl_uc2.rb