examples/ssl_uc2.rb in stomp-1.4.1 vs examples/ssl_uc2.rb in stomp-1.4.2
- old
+ new
@@ -1,12 +1,17 @@
# -*- encoding: utf-8 -*-
#
# Reference: https://github.com/stompgem/stomp/wiki/extended-ssl-overview
#
-require "rubygems"
-require "stomp"
+if Kernel.respond_to?(:require_relative)
+ require_relative("./ssl_common")
+else
+ $LOAD_PATH << File.dirname(__FILE__)
+ require "ssl_common"
+end
+include SSLCommon
#
# == SSL Use Case 2 - server does *not* authenticate client, client *does* authenticate server
#
# Subcase 2.A - Message broker configuration does *not* require client authentication
#
@@ -19,22 +24,21 @@
# - Expect connection failure (broker must be sent a valid client certificate)
#
class ExampleSSL2
# Initialize.
def initialize
- # Change the following to the location of the cert file(s).
- @cert_loc = "/ad3/gma/sslwork/2013"
+ # Change the following as needed.
@host = ENV['STOMP_HOST'] ? ENV['STOMP_HOST'] : "localhost"
@port = ENV['STOMP_PORT'] ? ENV['STOMP_PORT'].to_i : 61612
end
# Run example.
def run
puts "Connect host: #{@host}, port: #{@port}"
ts_flist = []
- # Possibly change the cert file(s) name(s) here.
- ts_flist << "#{@cert_loc}/TestCA.crt"
+ # Possibly change/override the cert data here.
+ ts_flist << "#{ca_loc()}/#{ca_cert()}"
ssl_opts = Stomp::SSLParams.new(:ts_files => ts_flist.join(","),
:fsck => true)
#
hash = { :hosts => [