stomp 1.4.4 → 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +13 -0
- data/README.md +96 -100
- data/examples/EXAMPLES.md +251 -0
- data/examples/amqdurasub.rb +14 -17
- data/examples/artemis/cliwaiter_not_reliable.rb +12 -5
- data/examples/artemis/{cliwaiter_reliable.rb → cliwaiter_reliable_hb.rb} +24 -23
- data/examples/client_conndisc.rb +66 -0
- data/examples/client_putget.rb +94 -0
- data/examples/conn_conndisc.rb +102 -0
- data/examples/conn_putget.rb +124 -0
- data/examples/contrib.sh +2 -3
- data/examples/contributors.rb +26 -14
- data/examples/examplogger.rb +1 -1
- data/examples/{consumer.rb → historical/consumer.rb} +0 -0
- data/examples/{publisher.rb → historical/publisher.rb} +0 -0
- data/examples/{topic_consumer.rb → historical/topic_consumer.rb} +0 -0
- data/examples/{topic_publisher.rb → historical/topic_publisher.rb} +0 -0
- data/examples/logexamp.rb +23 -14
- data/examples/putget_file.rb +79 -0
- data/examples/{putget11_rh1.rb → putget_rephdrs.rb} +16 -15
- data/examples/ssl/SSL.md +189 -0
- data/examples/{ssl_ctxoptions.rb → ssl/misc/ssl_ctxoptions.rb} +23 -14
- data/examples/ssl/misc/ssl_newparm.rb +53 -0
- data/examples/ssl/misc/ssl_ucx_default_ciphers.rb +54 -0
- data/examples/ssl/ssl_common.rb +96 -0
- data/examples/ssl/sslexall.sh +17 -0
- data/examples/{ssl_uc1.rb → ssl/uc1/ssl_uc1.rb} +15 -11
- data/examples/ssl/uc1/ssl_uc1_ciphers.rb +60 -0
- data/examples/{ssl_uc2.rb → ssl/uc2/ssl_uc2.rb} +17 -10
- data/examples/ssl/uc2/ssl_uc2_ciphers.rb +67 -0
- data/examples/{ssl_uc3.rb → ssl/uc3/ssl_uc3.rb} +15 -16
- data/examples/ssl/uc3/ssl_uc3_ciphers.rb +65 -0
- data/examples/{ssl_uc4.rb → ssl/uc4/ssl_uc4.rb} +15 -15
- data/examples/ssl/uc4/ssl_uc4_ciphers.rb +66 -0
- data/examples/stomp_common.rb +97 -0
- data/lib/connection/netio.rb +83 -37
- data/lib/connection/utf8.rb +0 -7
- data/lib/connection/utils.rb +4 -1
- data/lib/stomp/client.rb +5 -1
- data/lib/stomp/connection.rb +25 -15
- data/lib/stomp/constants.rb +109 -0
- data/lib/stomp/errors.rb +11 -0
- data/lib/stomp/sslparams.rb +3 -4
- data/lib/stomp/version.rb +2 -2
- data/stomp.gemspec +31 -37
- data/test/test_anonymous.rb +4 -0
- data/test/test_client.rb +2 -0
- data/test/test_connection.rb +4 -0
- data/test/test_connection1p.rb +2 -4
- data/test/test_helper.rb +11 -0
- metadata +30 -36
- data/examples/artemis/artlogger.rb +0 -41
- data/examples/client11_ex1.rb +0 -89
- data/examples/client11_putget1.rb +0 -71
- data/examples/conn11_ex1.rb +0 -112
- data/examples/conn11_ex2.rb +0 -87
- data/examples/conn11_hb1.rb +0 -57
- data/examples/consume_file.rb +0 -63
- data/examples/get11conn_ex1.rb +0 -117
- data/examples/get11conn_ex2.rb +0 -77
- data/examples/lflogger.rb +0 -316
- data/examples/logexamp_ssl.rb +0 -81
- data/examples/publish_file.rb +0 -76
- data/examples/publish_file_conn.rb +0 -75
- data/examples/put11conn_ex1.rb +0 -56
- data/examples/ssl_common.rb +0 -73
- data/examples/ssl_newparm.rb +0 -43
- data/examples/ssl_uc1_ciphers.rb +0 -53
- data/examples/ssl_uc2_ciphers.rb +0 -60
- data/examples/ssl_uc3_ciphers.rb +0 -64
- data/examples/ssl_uc4_ciphers.rb +0 -65
- data/examples/ssl_ucx_default_ciphers.rb +0 -41
- data/examples/stomp11_common.rb +0 -54
@@ -0,0 +1,53 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
#
|
4
|
+
# Reference: https://github.com/stompgem/stomp/wiki/extended-ssl-overview
|
5
|
+
#
|
6
|
+
if Kernel.respond_to?(:require_relative)
|
7
|
+
require_relative("../ssl_common")
|
8
|
+
require_relative("../../stomp_common")
|
9
|
+
else
|
10
|
+
$LOAD_PATH << File.dirname(__FILE__)
|
11
|
+
require "../ssl_common"
|
12
|
+
require "../../stomp_common"
|
13
|
+
end
|
14
|
+
include SSLCommon
|
15
|
+
include Stomp1xCommon
|
16
|
+
#
|
17
|
+
# == Demo override of SSLContext.new parameters.
|
18
|
+
#
|
19
|
+
# Based roughly on example ssl_uc1.rb.
|
20
|
+
#
|
21
|
+
#
|
22
|
+
class ExampleSSLNewParm
|
23
|
+
# Initialize.
|
24
|
+
def initialize
|
25
|
+
@port = ENV['STOMP_PORT'] ? ENV['STOMP_PORT'].to_i : 61611
|
26
|
+
end
|
27
|
+
# Run example.
|
28
|
+
def run
|
29
|
+
ssl_opts = Stomp::SSLParams.new()
|
30
|
+
hash = { :hosts => [
|
31
|
+
{:login => login(), :passcode => passcode(), :host => host(), :port => @port, :ssl => ssl_opts},
|
32
|
+
],
|
33
|
+
:reliable => false, # YMMV, to test this in a sane manner
|
34
|
+
# This parameter is passed by the gem to the new method for ssl context.
|
35
|
+
:sslctx_newparm => :TLSv1, # An example, try to force TLSv1
|
36
|
+
# If your version of Ruby does not support what you ask for, Ruby openssl code will raise
|
37
|
+
# an exception. If Ruby accepts your parms, but your broker does not you will get
|
38
|
+
# different errors (depending on broker).
|
39
|
+
}
|
40
|
+
#
|
41
|
+
puts "Connect starts, Demo SSL context new parameters"
|
42
|
+
c = Stomp::Connection.new(hash)
|
43
|
+
puts "Connect completed"
|
44
|
+
puts "SSL Verify Result: #{ssl_opts.verify_result}"
|
45
|
+
puts "SSL Peer Certificate:\n#{ssl_opts.peer_cert}" if showPeerCert()
|
46
|
+
#
|
47
|
+
c.disconnect()
|
48
|
+
end
|
49
|
+
end
|
50
|
+
#
|
51
|
+
e = ExampleSSLNewParm.new()
|
52
|
+
e.run()
|
53
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
#
|
4
|
+
# Reference: https://github.com/stompgem/stomp/wiki/extended-ssl-overview
|
5
|
+
#
|
6
|
+
if Kernel.respond_to?(:require_relative)
|
7
|
+
require_relative("../ssl_common")
|
8
|
+
require_relative("../../stomp_common")
|
9
|
+
else
|
10
|
+
$LOAD_PATH << File.dirname(__FILE__)
|
11
|
+
require "../ssl_common"
|
12
|
+
require "../../stomp_common"
|
13
|
+
end
|
14
|
+
include SSLCommon
|
15
|
+
include Stomp1xCommon
|
16
|
+
#
|
17
|
+
# == Example: Use Ruby Supplied Ciphers
|
18
|
+
#
|
19
|
+
# If you use SSLParams, and need the _default_ Ruby ciphers, this is how.
|
20
|
+
#
|
21
|
+
# NOTE: JRuby users may find that this is a *required* action. YMMV.
|
22
|
+
#
|
23
|
+
class ExampleRubyCiphers
|
24
|
+
# Initialize.
|
25
|
+
def initialize
|
26
|
+
# It is very likely that you will have to specify your specific port number.
|
27
|
+
# 61611 is currently my AMQ local port number for ssl client auth not required.
|
28
|
+
@port = ENV['STOMP_PORT'] ? ENV['STOMP_PORT'].to_i : 61611
|
29
|
+
end
|
30
|
+
# Run example.
|
31
|
+
def run()
|
32
|
+
puts "SSLUCXRDF Connect host: #{host()}, port: #{@port}"
|
33
|
+
ssl_opts = Stomp::SSLParams.new(:use_ruby_ciphers => true) # Plus other parameters as needed
|
34
|
+
puts "SSLOPTS: #{ssl_opts.inspect}"
|
35
|
+
#
|
36
|
+
# SSL Use Case: Using default Ruby ciphers
|
37
|
+
#
|
38
|
+
hash = { :hosts => [
|
39
|
+
{:login => login(), :passcode => passcode(), :host => host(),
|
40
|
+
:port => @port, :ssl => ssl_opts},
|
41
|
+
]
|
42
|
+
}
|
43
|
+
#
|
44
|
+
puts "Connect starts, SSL , Use Default Ruby Ciphers"
|
45
|
+
c = Stomp::Connection.new(hash)
|
46
|
+
puts "Connect completed"
|
47
|
+
#
|
48
|
+
c.disconnect()
|
49
|
+
end
|
50
|
+
end
|
51
|
+
#
|
52
|
+
e = ExampleRubyCiphers.new()
|
53
|
+
e.run()
|
54
|
+
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
#
|
4
|
+
# Common Stomp 1.1 code.
|
5
|
+
#
|
6
|
+
require "rubygems" if RUBY_VERSION < "1.9"
|
7
|
+
require "stomp"
|
8
|
+
#
|
9
|
+
module SSLCommon
|
10
|
+
|
11
|
+
# CA Data.
|
12
|
+
|
13
|
+
# CA cert file location/directory. Change or specify.
|
14
|
+
# This is the author's default.
|
15
|
+
def ca_loc()
|
16
|
+
ENV['CA_FLOC'] || "/ad3/gma/ad3/sslwork/2017-01" # The CA cert location
|
17
|
+
end
|
18
|
+
|
19
|
+
# CA cert file. Change or specify.
|
20
|
+
# This is the author's default.
|
21
|
+
def ca_cert()
|
22
|
+
ENV['CA_FILE'] || "ca.crt" # The CA cert File
|
23
|
+
end
|
24
|
+
|
25
|
+
# CA private key file name. Change or specify.
|
26
|
+
# This is the author's default.
|
27
|
+
# This file should not be exposed to the outside world.
|
28
|
+
# Not currently used/needed in stomp examples.
|
29
|
+
def ca_key()
|
30
|
+
ENV['CA_KEY'] || nil # The CA private key File
|
31
|
+
end
|
32
|
+
|
33
|
+
# Client Data.
|
34
|
+
|
35
|
+
# Client cert file location/directory. Change or specify.
|
36
|
+
# This is the author's default.
|
37
|
+
def cli_loc()
|
38
|
+
ENV['CLI_FLOC'] || "/ad3/gma/ad3/sslwork/2017-01" # The client cert location
|
39
|
+
end
|
40
|
+
|
41
|
+
# Client cert file name. Change or specify.
|
42
|
+
# This is the author's default.
|
43
|
+
def cli_cert()
|
44
|
+
ENV['CLI_FILE'] || "client.crt" # The client cert File
|
45
|
+
end
|
46
|
+
|
47
|
+
# Client private key file name. Change or specify.
|
48
|
+
# This is the author's default.
|
49
|
+
# This file should not be exposed to the outside world.
|
50
|
+
def cli_key()
|
51
|
+
ENV['CLI_KEY'] || pck() # The client private key File
|
52
|
+
end
|
53
|
+
|
54
|
+
# Server Data.
|
55
|
+
|
56
|
+
# Server file location/directory. Change or specify.
|
57
|
+
# This is the author's default.
|
58
|
+
# Not currently used in stomp examples.
|
59
|
+
def svr_loc()
|
60
|
+
ENV['SVR_FLOC'] || "/ad3/gma/ad3/sslwork/2017-01" # The server cert location
|
61
|
+
end
|
62
|
+
|
63
|
+
# Server cert file. Change or specify.
|
64
|
+
# This is the author's default.
|
65
|
+
# Not currently used in stomp examples.
|
66
|
+
def svr_cert()
|
67
|
+
ENV['SVR_FILE'] || "server.crt" # The server cert File
|
68
|
+
end
|
69
|
+
|
70
|
+
# Server private keyfile. Change or specify.
|
71
|
+
# This is the author's default.
|
72
|
+
# This file should not be exposed to the outside world.
|
73
|
+
# Not currently used in stomp examples.
|
74
|
+
def svr_key()
|
75
|
+
ENV['SVR_KEY'] || nil # The server private key File
|
76
|
+
end
|
77
|
+
# Show peer cert or not
|
78
|
+
def showPeerCert()
|
79
|
+
ENV['SHOWPEERCERT'] || false
|
80
|
+
end
|
81
|
+
|
82
|
+
# Ciphers list for the ciphers examples
|
83
|
+
def ciphers_list()
|
84
|
+
[["DHE-RSA-AES256-SHA", "TLSv1/SSLv3", 256, 256], ["DHE-DSS-AES256-SHA", "TLSv1/SSLv3", 256, 256], ["AES256-SHA", "TLSv1/SSLv3", 256, 256], ["EDH-RSA-DES-CBC3-SHA", "TLSv1/SSLv3", 168, 168], ["EDH-DSS-DES-CBC3-SHA", "TLSv1/SSLv3", 168, 168], ["DES-CBC3-SHA", "TLSv1/SSLv3", 168, 168], ["DHE-RSA-AES128-SHA", "TLSv1/SSLv3", 128, 128], ["DHE-DSS-AES128-SHA", "TLSv1/SSLv3", 128, 128], ["AES128-SHA", "TLSv1/SSLv3", 128, 128], ["RC4-SHA", "TLSv1/SSLv3", 128, 128], ["RC4-MD5", "TLSv1/SSLv3", 128, 128], ["EDH-RSA-DES-CBC-SHA", "TLSv1/SSLv3", 56, 56], ["EDH-DSS-DES-CBC-SHA", "TLSv1/SSLv3", 56, 56], ["DES-CBC-SHA", "TLSv1/SSLv3", 56, 56], ["EXP-EDH-RSA-DES-CBC-SHA", "TLSv1/SSLv3", 40, 56], ["EXP-EDH-DSS-DES-CBC-SHA", "TLSv1/SSLv3", 40, 56], ["EXP-DES-CBC-SHA", "TLSv1/SSLv3", 40, 56], ["EXP-RC2-CBC-MD5", "TLSv1/SSLv3", 40, 128], ["EXP-RC4-MD5", "TLSv1/SSLv3", 40, 128]]
|
85
|
+
end
|
86
|
+
|
87
|
+
# Private
|
88
|
+
private
|
89
|
+
|
90
|
+
# Client Key File
|
91
|
+
def pck()
|
92
|
+
"client.key"
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
#
|
3
|
+
ruby -I ../../lib uc1/ssl_uc1.rb
|
4
|
+
echo "=============================="
|
5
|
+
ruby -I ../../lib uc1/ssl_uc1_ciphers.rb
|
6
|
+
echo "=============================="
|
7
|
+
ruby -I ../../lib uc2/ssl_uc2.rb
|
8
|
+
echo "=============================="
|
9
|
+
ruby -I ../../lib uc2/ssl_uc2_ciphers.rb
|
10
|
+
echo "=============================="
|
11
|
+
ruby -I ../../lib uc3/ssl_uc3.rb
|
12
|
+
echo "=============================="
|
13
|
+
ruby -I ../../lib uc3/ssl_uc3_ciphers.rb
|
14
|
+
echo "=============================="
|
15
|
+
ruby -I ../../lib uc4/ssl_uc4.rb
|
16
|
+
echo "=============================="
|
17
|
+
ruby -I ../../lib uc4/ssl_uc4_ciphers.rb
|
@@ -5,12 +5,15 @@
|
|
5
5
|
#
|
6
6
|
#
|
7
7
|
if Kernel.respond_to?(:require_relative)
|
8
|
-
require_relative("
|
8
|
+
require_relative("../ssl_common")
|
9
|
+
require_relative("../../stomp_common")
|
9
10
|
else
|
10
11
|
$LOAD_PATH << File.dirname(__FILE__)
|
11
|
-
require "ssl_common"
|
12
|
+
require "../ssl_common"
|
13
|
+
require "../../stomp_common"
|
12
14
|
end
|
13
15
|
include SSLCommon
|
16
|
+
include Stomp1xCommon
|
14
17
|
#
|
15
18
|
# == SSL Use Case 1 - server does *not* authenticate client, client does *not* authenticate server
|
16
19
|
#
|
@@ -27,18 +30,19 @@ include SSLCommon
|
|
27
30
|
class ExampleSSL1
|
28
31
|
# Initialize.
|
29
32
|
def initialize # Change the following as needed.
|
30
|
-
|
31
|
-
|
33
|
+
@host = host()
|
34
|
+
# It is very likely that you will have to specify your specific port number.
|
35
|
+
# 61611 is currently my AMQ local port number for ssl client auth not required.
|
36
|
+
@port = ENV['STOMP_PORT'] ? ENV['STOMP_PORT'].to_i : 61611
|
32
37
|
end
|
33
38
|
# Run example.
|
34
39
|
def run
|
35
|
-
puts "Connect host: #{@host}, port: #{@port}"
|
40
|
+
puts "SSLUC1 Connect host: #{@host}, port: #{@port}"
|
36
41
|
|
37
42
|
ssl_opts = Stomp::SSLParams.new # or ssl_opts = true (for this use case)
|
38
|
-
|
39
|
-
|
43
|
+
puts "SSLOPTS: #{ssl_opts.inspect}"
|
40
44
|
hash = { :hosts => [
|
41
|
-
{:login =>
|
45
|
+
{:login => login(), :passcode => passcode(), :host => @host, :port => @port, :ssl => ssl_opts},
|
42
46
|
],
|
43
47
|
:reliable => false, # YMMV, to test this in a sane manner
|
44
48
|
}
|
@@ -47,11 +51,11 @@ class ExampleSSL1
|
|
47
51
|
c = Stomp::Connection.new(hash)
|
48
52
|
puts "Connect completed"
|
49
53
|
puts "SSL Verify Result: #{ssl_opts.verify_result}"
|
50
|
-
|
54
|
+
puts "SSL Peer Certificate:\n#{ssl_opts.peer_cert}" if showPeerCert()
|
51
55
|
#
|
52
|
-
c.disconnect
|
56
|
+
c.disconnect()
|
53
57
|
end
|
54
58
|
end
|
55
59
|
#
|
56
|
-
e = ExampleSSL1.new
|
60
|
+
e = ExampleSSL1.new()
|
57
61
|
e.run
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
#
|
4
|
+
# Reference: https://github.com/stompgem/stomp/wiki/extended-ssl-overview
|
5
|
+
#
|
6
|
+
if Kernel.respond_to?(:require_relative)
|
7
|
+
require_relative("../ssl_common")
|
8
|
+
require_relative("../../stomp_common")
|
9
|
+
else
|
10
|
+
$LOAD_PATH << File.dirname(__FILE__)
|
11
|
+
require "../ssl_common"
|
12
|
+
require "../../stomp_common"
|
13
|
+
end
|
14
|
+
include SSLCommon
|
15
|
+
include Stomp1xCommon
|
16
|
+
#
|
17
|
+
# == SSL Use Case 1 - User Supplied Ciphers
|
18
|
+
#
|
19
|
+
# If you need your own ciphers list, this is how.
|
20
|
+
# Stomp's default list will work in many cases. If you need to use this, you
|
21
|
+
# will know it because SSL connect will fail. In that case, determining
|
22
|
+
# _what_ should be in the list is your responsibility.
|
23
|
+
#
|
24
|
+
class ExampleSSL1C
|
25
|
+
# Initialize.
|
26
|
+
def initialize # Change the following as needed.
|
27
|
+
@host = host()
|
28
|
+
# It is very likely that you will have to specify your specific port number.
|
29
|
+
# 61611 is currently my AMQ local port number for ssl client auth not required.
|
30
|
+
@port = ENV['STOMP_PORT'] ? ENV['STOMP_PORT'].to_i : 61611
|
31
|
+
end
|
32
|
+
# Run example.
|
33
|
+
def run
|
34
|
+
puts "SSLUC1C Connect host: #{@host}, port: #{@port}"
|
35
|
+
|
36
|
+
ssl_opts = Stomp::SSLParams.new(:ciphers => ciphers_list())
|
37
|
+
puts "SSLOPTS: #{ssl_opts.inspect}"
|
38
|
+
|
39
|
+
#
|
40
|
+
# SSL Use Case 1
|
41
|
+
#
|
42
|
+
hash = { :hosts => [
|
43
|
+
{:login => login(), :passcode => passcode(), :host => @host, :port => @port, :ssl => ssl_opts},
|
44
|
+
],
|
45
|
+
:reliable => false, # YMMV, to test this in a sane manner
|
46
|
+
}
|
47
|
+
#
|
48
|
+
puts "Connect starts, SSL Use Case 1"
|
49
|
+
c = Stomp::Connection.new(hash)
|
50
|
+
puts "Connect completed"
|
51
|
+
puts "SSL Verify Result: #{ssl_opts.verify_result}"
|
52
|
+
puts "SSL Peer Certificate:\n#{ssl_opts.peer_cert}" if showPeerCert()
|
53
|
+
#
|
54
|
+
c.disconnect()
|
55
|
+
end
|
56
|
+
end
|
57
|
+
#
|
58
|
+
e = ExampleSSL1C.new()
|
59
|
+
e.run
|
60
|
+
|
@@ -4,12 +4,15 @@
|
|
4
4
|
# Reference: https://github.com/stompgem/stomp/wiki/extended-ssl-overview
|
5
5
|
#
|
6
6
|
if Kernel.respond_to?(:require_relative)
|
7
|
-
require_relative("
|
7
|
+
require_relative("../ssl_common")
|
8
|
+
require_relative("../../stomp_common")
|
8
9
|
else
|
9
10
|
$LOAD_PATH << File.dirname(__FILE__)
|
10
|
-
require "ssl_common"
|
11
|
+
require "../ssl_common"
|
12
|
+
require("../../stomp_common")
|
11
13
|
end
|
12
14
|
include SSLCommon
|
15
|
+
include Stomp1xCommon
|
13
16
|
#
|
14
17
|
# == SSL Use Case 2 - server does *not* authenticate client, client *does* authenticate server
|
15
18
|
#
|
@@ -27,23 +30,27 @@ class ExampleSSL2
|
|
27
30
|
# Initialize.
|
28
31
|
def initialize
|
29
32
|
# Change the following as needed.
|
30
|
-
|
31
|
-
|
33
|
+
@host = host()
|
34
|
+
# It is very likely that you will have to specify your specific port number.
|
35
|
+
# 61611 is currently my AMQ local port number for ssl client auth is not required.
|
36
|
+
@port = ENV['STOMP_PORT'] ? ENV['STOMP_PORT'].to_i : 61611
|
32
37
|
end
|
33
38
|
# Run example.
|
34
39
|
def run
|
35
|
-
puts "Connect host: #{@host}, port: #{@port}"
|
40
|
+
puts "SSLUC2 Connect host: #{@host}, port: #{@port}"
|
36
41
|
|
37
42
|
ts_flist = []
|
38
43
|
|
39
44
|
# Possibly change/override the cert data here.
|
40
|
-
|
45
|
+
ts_flist << "#{ca_loc()}/#{ca_cert()}"
|
46
|
+
puts "TSFLIST: #{ts_flist.inspect}"
|
41
47
|
|
42
48
|
ssl_opts = Stomp::SSLParams.new(:ts_files => ts_flist.join(","),
|
43
49
|
:fsck => true)
|
50
|
+
puts "SSLOPTS: #{ssl_opts.inspect}"
|
44
51
|
#
|
45
52
|
hash = { :hosts => [
|
46
|
-
{:login =>
|
53
|
+
{:login => login(), :passcode => passcode(), :host => @host, :port => @port, :ssl => ssl_opts},
|
47
54
|
],
|
48
55
|
:reliable => false, # YMMV, to test this in a sane manner
|
49
56
|
}
|
@@ -52,11 +59,11 @@ class ExampleSSL2
|
|
52
59
|
c = Stomp::Connection.new(hash)
|
53
60
|
puts "Connect completed"
|
54
61
|
puts "SSL Verify Result: #{ssl_opts.verify_result}"
|
55
|
-
|
56
|
-
c.disconnect
|
62
|
+
puts "SSL Peer Certificate:\n#{ssl_opts.peer_cert}" if showPeerCert()
|
63
|
+
c.disconnect()
|
57
64
|
end
|
58
65
|
end
|
59
66
|
#
|
60
|
-
e = ExampleSSL2.new
|
67
|
+
e = ExampleSSL2.new()
|
61
68
|
e.run
|
62
69
|
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
#
|
4
|
+
# Reference: https://github.com/stompgem/stomp/wiki/extended-ssl-overview
|
5
|
+
#
|
6
|
+
if Kernel.respond_to?(:require_relative)
|
7
|
+
require_relative("../ssl_common")
|
8
|
+
require_relative("../../stomp_common")
|
9
|
+
else
|
10
|
+
$LOAD_PATH << File.dirname(__FILE__)
|
11
|
+
require "../ssl_common"
|
12
|
+
require("../../stomp_common")
|
13
|
+
end
|
14
|
+
include SSLCommon
|
15
|
+
include Stomp1xCommon
|
16
|
+
#
|
17
|
+
# == SSL Use Case 2 - User Supplied Ciphers
|
18
|
+
#
|
19
|
+
# If you need your own ciphers list, this is how.
|
20
|
+
# Stomp's default list will work in many cases. If you need to use this, you
|
21
|
+
# will know it because SSL connect will fail. In that case, determining
|
22
|
+
# _what_ should be in the list is your responsibility.
|
23
|
+
#
|
24
|
+
class ExampleSSL2C
|
25
|
+
# Initialize.
|
26
|
+
def initialize # Change the following as needed.
|
27
|
+
@host = host()
|
28
|
+
# It is very likely that you will have to specify your specific port number.
|
29
|
+
# 61611 is currently my AMQ local port number for ssl client auth is not required.
|
30
|
+
@port = ENV['STOMP_PORT'] ? ENV['STOMP_PORT'].to_i : 61611
|
31
|
+
end
|
32
|
+
# Run example.
|
33
|
+
def run
|
34
|
+
puts "SSLUC2C Connect host: #{@host}, port: #{@port}"
|
35
|
+
#
|
36
|
+
# SSL Use Case 2
|
37
|
+
#
|
38
|
+
ts_flist = []
|
39
|
+
|
40
|
+
# Possibly change/override the cert data here.
|
41
|
+
ts_flist << "#{ca_loc()}/#{ca_cert()}"
|
42
|
+
puts "TSFLIST: #{ts_flist.inspect}"
|
43
|
+
|
44
|
+
ssl_opts = Stomp::SSLParams.new(:ts_files => ts_flist.join(","),
|
45
|
+
:ciphers => ciphers_list(), # The cipher list
|
46
|
+
:fsck => true
|
47
|
+
)
|
48
|
+
puts "SSLOPTS: #{ssl_opts.inspect}"
|
49
|
+
#
|
50
|
+
hash = { :hosts => [
|
51
|
+
{:login => login(), :passcode => passcode(), :host => @host, :port => @port, :ssl => ssl_opts},
|
52
|
+
],
|
53
|
+
:reliable => false, # YMMV, to test this in a sane manner
|
54
|
+
}
|
55
|
+
#
|
56
|
+
puts "Connect starts, SSL Use Case 2"
|
57
|
+
c = Stomp::Connection.new(hash)
|
58
|
+
puts "Connect completed"
|
59
|
+
puts "SSL Verify Result: #{ssl_opts.verify_result}"
|
60
|
+
puts "SSL Peer Certificate:\n#{ssl_opts.peer_cert}" if showPeerCert()
|
61
|
+
c.disconnect()
|
62
|
+
end
|
63
|
+
end
|
64
|
+
#
|
65
|
+
e = ExampleSSL2C.new()
|
66
|
+
e.run
|
67
|
+
|