stomp 1.4.4 → 1.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
data/examples/examplogger.rb
CHANGED
@@ -11,7 +11,7 @@ require 'logger' # use the standard Ruby logger .....
|
|
11
11
|
# * on_connectfail: unsuccessful connect (will usually be retried)
|
12
12
|
# * on_disconnect: successful disconnect
|
13
13
|
#
|
14
|
-
# * on_miscerr: on miscellaneous
|
14
|
+
# * on_miscerr: on miscellaneous transmit/receive errors
|
15
15
|
#
|
16
16
|
# * on_publish: publish called
|
17
17
|
# * on_subscribe: subscribe called
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/examples/logexamp.rb
CHANGED
@@ -5,13 +5,19 @@ require 'stomp'
|
|
5
5
|
require 'logger' # for the 'local' logger
|
6
6
|
#
|
7
7
|
if Kernel.respond_to?(:require_relative)
|
8
|
+
require_relative("./stomp_common")
|
8
9
|
require_relative("./examplogger")
|
9
10
|
else
|
10
11
|
$LOAD_PATH << File.dirname(__FILE__)
|
11
12
|
require "examplogger"
|
13
|
+
require("stomp_common")
|
12
14
|
end
|
15
|
+
include Stomp1xCommon
|
13
16
|
#
|
14
|
-
# == A
|
17
|
+
# == A program which demonstrates the callback logging facility.
|
18
|
+
#
|
19
|
+
# With appropriate specification of STOMP_PORT, this code should also
|
20
|
+
# demonstrate failover.
|
15
21
|
#
|
16
22
|
class LoggerExample
|
17
23
|
# Initialize.
|
@@ -25,18 +31,20 @@ class LoggerExample
|
|
25
31
|
|
26
32
|
# //////////////////////////////////////////////////////////////////////////////
|
27
33
|
mylog = Slogger::new # The client provided STOMP callback logger
|
28
|
-
|
29
34
|
# //////////////////////////////////////////////////////////////////////////////
|
30
35
|
user = ENV['STOMP_USER'] ? ENV['STOMP_USER'] : 'guest'
|
31
36
|
password = ENV['STOMP_PASSWORD'] ? ENV['STOMP_PASSWORD'] : 'guest'
|
32
37
|
host = ENV['STOMP_HOST'] ? ENV['STOMP_HOST'] : 'localhost'
|
33
38
|
port = ENV['STOMP_PORT'] ? ENV['STOMP_PORT'].to_i : 61613
|
39
|
+
so = usessl()
|
34
40
|
# //////////////////////////////////////////////////////////////////////////////
|
35
41
|
# A hash type connect *MUST* be used to enable callback logging.
|
36
42
|
# //////////////////////////////////////////////////////////////////////////////
|
37
43
|
hash = { :hosts => [
|
38
|
-
{:login => user, :passcode => password, :host => 'noonehome', :port => 2525
|
39
|
-
|
44
|
+
{:login => user, :passcode => password, :host => 'noonehome', :port => 2525,
|
45
|
+
:ssl => so},
|
46
|
+
{:login => user, :passcode => password, :host => host, :port => port,
|
47
|
+
:ssl => so},
|
40
48
|
],
|
41
49
|
:logger => mylog, # This enables callback logging!
|
42
50
|
:max_reconnect_attempts => 5,
|
@@ -46,15 +54,17 @@ class LoggerExample
|
|
46
54
|
# For a Connection:
|
47
55
|
llog.debug "LE Connection processing starts"
|
48
56
|
conn = Stomp::Connection.new(hash)
|
49
|
-
conn.disconnect
|
57
|
+
conn.disconnect()
|
58
|
+
|
50
59
|
# //////////////////////////////////////////////////////////////////////////////
|
51
60
|
llog.debug "LE Connection processing complete"
|
52
61
|
|
53
62
|
# //////////////////////////////////////////////////////////////////////////////
|
54
63
|
# For a Client:
|
55
64
|
llog.debug "LE Client processing starts"
|
56
|
-
|
57
|
-
|
65
|
+
client = Stomp::Client.new(hash)
|
66
|
+
client.close()
|
67
|
+
|
58
68
|
# //////////////////////////////////////////////////////////////////////////////
|
59
69
|
llog.debug "LE Client processing complete"
|
60
70
|
|
@@ -65,9 +75,10 @@ class LoggerExample
|
|
65
75
|
#
|
66
76
|
dest = "/queue/loggerq1"
|
67
77
|
conn.publish dest, "a logger message"
|
68
|
-
conn.subscribe
|
69
|
-
msg = conn.receive
|
70
|
-
conn.disconnect
|
78
|
+
conn.subscribe(dest)
|
79
|
+
msg = conn.receive()
|
80
|
+
conn.disconnect()
|
81
|
+
|
71
82
|
# //////////////////////////////////////////////////////////////////////////////
|
72
83
|
llog.debug "LE Connection Enhanced processing complete"
|
73
84
|
|
@@ -75,7 +86,5 @@ class LoggerExample
|
|
75
86
|
llog.debug "LE Ending"
|
76
87
|
end
|
77
88
|
end
|
78
|
-
e = LoggerExample.new
|
79
|
-
e.run
|
80
|
-
|
81
|
-
|
89
|
+
e = LoggerExample.new()
|
90
|
+
e.run()
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'stomp'
|
5
|
+
|
6
|
+
if Kernel.respond_to?(:require_relative)
|
7
|
+
require_relative("./stomp_common")
|
8
|
+
else
|
9
|
+
$LOAD_PATH << File.dirname(__FILE__)
|
10
|
+
require "stomp_common"
|
11
|
+
end
|
12
|
+
include Stomp1xCommon
|
13
|
+
#
|
14
|
+
# Used primarily for testing performance when sending/receiving "large" messages.
|
15
|
+
# "large" => YMMV
|
16
|
+
#
|
17
|
+
class FilePutGet
|
18
|
+
# Initialize.
|
19
|
+
def initialize
|
20
|
+
@qname = dest()
|
21
|
+
end
|
22
|
+
# Run put part of example.
|
23
|
+
def doput()
|
24
|
+
puts
|
25
|
+
puts "pgf001 - put starts"
|
26
|
+
start_time = Time.now.to_f
|
27
|
+
fname = ARGV[0]
|
28
|
+
puts "pgf002: File Name: #{fname}"
|
29
|
+
file = open(fname, "r")
|
30
|
+
rs = Time.now.to_f
|
31
|
+
buff = file.read
|
32
|
+
re = Time.now.to_f
|
33
|
+
ppt = sprintf("%22.8f", re - rs)
|
34
|
+
puts "pgf003: File size: #{buff.respond_to?(:bytesize) ? buff.bytesize : buff.length} bytes"
|
35
|
+
puts "pgf004: File read time: #{ppt} seconds"
|
36
|
+
file.close
|
37
|
+
#
|
38
|
+
conn = get_connection()
|
39
|
+
puts "pgf005: Qname is: #{@qname}"
|
40
|
+
# Try to gracefully handle files that exceed broker size limits.
|
41
|
+
ph = {:presistent => true}
|
42
|
+
ph['suppress_content_length'] = 'yes' if suppresscl()
|
43
|
+
puts "pgf006: Headers are: #{ph.inspect}"
|
44
|
+
begin
|
45
|
+
conn.publish(@qname, buff, ph)
|
46
|
+
rescue
|
47
|
+
puts "pgf900: exception on publish: #{$!}"
|
48
|
+
raise
|
49
|
+
end
|
50
|
+
conn.disconnect()
|
51
|
+
end_time = Time.now.to_f
|
52
|
+
ppt = sprintf("%22.8f", end_time - start_time)
|
53
|
+
puts "pgf007: File publish time: #{ppt} seconds"
|
54
|
+
end
|
55
|
+
# Run get part of example.
|
56
|
+
def doget()
|
57
|
+
puts
|
58
|
+
puts "pgf101 - get starts"
|
59
|
+
start_time = Time.now.to_f
|
60
|
+
conn = get_connection()
|
61
|
+
uuid = conn.uuid() # uuid for Stomp::Connection is a public method
|
62
|
+
conn.subscribe(@qname, {'id' => uuid}) # Subscribe
|
63
|
+
msg = conn.receive()
|
64
|
+
puts "pgf102: Message Command: #{msg.command}"
|
65
|
+
puts "pgf103: Message Headers: #{msg.headers}"
|
66
|
+
body_length_bytes = msg.body.respond_to?(:bytesize) ? msg.body.bytesize : msg.body.length
|
67
|
+
puts "pgf104: Received: #{body_length_bytes} bytes"
|
68
|
+
#
|
69
|
+
end_time = Time.now.to_f
|
70
|
+
ppt = sprintf("%22.8f", end_time - start_time)
|
71
|
+
puts "pgf105: File receive time: #{ppt} seconds"
|
72
|
+
conn.disconnect()
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
#
|
77
|
+
e = FilePutGet.new()
|
78
|
+
e.doput()
|
79
|
+
e.doget()
|
@@ -5,21 +5,22 @@
|
|
5
5
|
# Change this to suit your requirements.
|
6
6
|
#
|
7
7
|
if Kernel.respond_to?(:require_relative)
|
8
|
-
require_relative("./
|
8
|
+
require_relative("./stomp_common")
|
9
9
|
else
|
10
10
|
$LOAD_PATH << File.dirname(__FILE__)
|
11
|
-
require "
|
11
|
+
require "stomp_common"
|
12
12
|
end
|
13
|
-
include
|
13
|
+
include Stomp1xCommon
|
14
14
|
#
|
15
|
-
# == Stomp 1.1 Send/Receive Example - Repeated Headers
|
15
|
+
# == Stomp 1.1+ Send/Receive Example - Repeated Headers
|
16
16
|
#
|
17
|
-
# Purpose: to demonstrate sending and receiving using Stomp 1.1
|
17
|
+
# Purpose: to demonstrate sending and receiving using Stomp 1.1+, and an unusual
|
18
18
|
# aspect of the specification. What is demonstrated here is the use of
|
19
19
|
# 'repeated headers'. Note that brokers MAY support repeated headers as
|
20
|
-
# demonstrated, but are not required to provide this support.
|
21
|
-
#
|
22
|
-
#
|
20
|
+
# demonstrated, but are not required to provide this support.
|
21
|
+
#
|
22
|
+
# This example should run against the Apollo broker. It will *not* currently run against
|
23
|
+
# ActiveMQ or RabbitMQ. YMMV depending on your broker.
|
23
24
|
#
|
24
25
|
# See: http://stomp.github.com/stomp-specification-1.1.html#Repeated_Header_Entries
|
25
26
|
#
|
@@ -30,7 +31,8 @@ class RepeatedHeadersExample
|
|
30
31
|
# Run example.
|
31
32
|
def run
|
32
33
|
conn = get_connection() # Use helper method to obtain a Stomp#connection
|
33
|
-
raise "Unexpected protocol level" if conn.protocol
|
34
|
+
raise "Unexpected protocol level" if conn.protocol == Stomp::SPL_10
|
35
|
+
puts "Repeated headers example, host: #{host()}, port: #{port()}"
|
34
36
|
#
|
35
37
|
# The gem supports repeated headers by allowing the 'value' part of a header
|
36
38
|
# to be an Array instance.
|
@@ -42,7 +44,7 @@ class RepeatedHeadersExample
|
|
42
44
|
# to hold the repeated values. This is presented the the calling client to
|
43
45
|
# be processed per client requirements.
|
44
46
|
#
|
45
|
-
qname =
|
47
|
+
qname = dest()
|
46
48
|
data = "message payload: #{Time.now.to_f}"
|
47
49
|
key2_repeats = ["key2val3", "key2val2", "key2val1" ]
|
48
50
|
headers = {"key1" => "value1", # A normal header
|
@@ -52,7 +54,7 @@ class RepeatedHeadersExample
|
|
52
54
|
#
|
53
55
|
# Ship it.
|
54
56
|
#
|
55
|
-
conn.publish
|
57
|
+
conn.publish(qname, data , headers)
|
56
58
|
puts "Sent data: #{data}"
|
57
59
|
#
|
58
60
|
# Receive phase.
|
@@ -84,10 +86,9 @@ class RepeatedHeadersExample
|
|
84
86
|
#
|
85
87
|
# And finally, disconnect.
|
86
88
|
#
|
87
|
-
conn.disconnect
|
89
|
+
conn.disconnect()
|
88
90
|
end
|
89
91
|
end
|
90
92
|
#
|
91
|
-
e = RepeatedHeadersExample.new
|
92
|
-
e.run
|
93
|
-
|
93
|
+
e = RepeatedHeadersExample.new()
|
94
|
+
e.run()
|
data/examples/ssl/SSL.md
ADDED
@@ -0,0 +1,189 @@
|
|
1
|
+
# SSL Examples
|
2
|
+
|
3
|
+
This is to provide additional documentation regarding the gem's
|
4
|
+
SSL related examples.
|
5
|
+
|
6
|
+
This documentation is based on experiments with OpenSSL.
|
7
|
+
|
8
|
+
|
9
|
+
## Environment Variables
|
10
|
+
|
11
|
+
You will likely need to use supported environment variables to
|
12
|
+
define SSL related data locations on your system. See example
|
13
|
+
ssl_common.rb for details of support of this functionality.
|
14
|
+
|
15
|
+
<table border="2" style="width:100%;border: 2px solid black;">
|
16
|
+
<tr>
|
17
|
+
<th style="border: 2px solid black;padding-left: 10px;" >
|
18
|
+
Environment Variable
|
19
|
+
</th>
|
20
|
+
<th style="border: 2px solid black;padding-left: 10px;" >
|
21
|
+
Description
|
22
|
+
</th>
|
23
|
+
</tr>
|
24
|
+
<!-- -->
|
25
|
+
<tr>
|
26
|
+
<td style="border: 2px solid black;padding-left: 10px;" >
|
27
|
+
CA_FLOC
|
28
|
+
</td>
|
29
|
+
<td style="border: 2px solid black;padding-left: 10px;" >
|
30
|
+
CA cert file location/directory.
|
31
|
+
</td>
|
32
|
+
</tr>
|
33
|
+
<!-- -->
|
34
|
+
<tr>
|
35
|
+
<td style="border: 2px solid black;padding-left: 10px;" >
|
36
|
+
CLI_FLOC
|
37
|
+
</td>
|
38
|
+
<td style="border: 2px solid black;padding-left: 10px;" >
|
39
|
+
Client cert file location/directory.
|
40
|
+
</td>
|
41
|
+
</tr>
|
42
|
+
<!-- -->
|
43
|
+
<tr>
|
44
|
+
<td style="border: 2px solid black;padding-left: 10px;" >
|
45
|
+
CLI_FILE
|
46
|
+
</td>
|
47
|
+
<td style="border: 2px solid black;padding-left: 10px;" >
|
48
|
+
Clent cert file name.
|
49
|
+
</td>
|
50
|
+
</tr>
|
51
|
+
<!-- -->
|
52
|
+
<tr>
|
53
|
+
<td style="border: 2px solid black;padding-left: 10px;" >
|
54
|
+
CLI_KEY
|
55
|
+
</td>
|
56
|
+
<td style="border: 2px solid black;padding-left: 10px;" >
|
57
|
+
Client private key file name. This file should not be
|
58
|
+
exposed to the outside world.
|
59
|
+
</td>
|
60
|
+
</tr>
|
61
|
+
<!-- -->
|
62
|
+
<tr>
|
63
|
+
<td style="border: 2px solid black;padding-left: 10px;" >
|
64
|
+
STOMP_HOST
|
65
|
+
</td>
|
66
|
+
<td style="border: 2px solid black;padding-left: 10px;" >
|
67
|
+
The host name of your SSL broker.
|
68
|
+
</td>
|
69
|
+
</tr>
|
70
|
+
<!-- -->
|
71
|
+
<tr>
|
72
|
+
<td style="border: 2px solid black;padding-left: 10px;" >
|
73
|
+
STOMP_PORT
|
74
|
+
</td>
|
75
|
+
<td style="border: 2px solid black;padding-left: 10px;" >
|
76
|
+
The the TCP port number used by your SSL broker.
|
77
|
+
</td>
|
78
|
+
</tr>
|
79
|
+
</table>
|
80
|
+
|
81
|
+
## The Four Main SSL Use Cases
|
82
|
+
|
83
|
+
There are four main SSL use cases. Example code for each of these can be found
|
84
|
+
in the 'examples/uc?' subdirectories. Each individual use case is described below.
|
85
|
+
|
86
|
+
Each 'sxamples/uc?' subdirectory contains two example programs:
|
87
|
+
|
88
|
+
* A primary demonstration of the example
|
89
|
+
* A secondary demonstration of the example where client code overrides the
|
90
|
+
default list of ciphers that SSL considers.
|
91
|
+
|
92
|
+
Note that each use case has two subcases:
|
93
|
+
|
94
|
+
* Your broker does _not_ require client authentication
|
95
|
+
* Your broker _does_ require client authentication
|
96
|
+
|
97
|
+
### Use Case 1 - No Authentification by broker or client
|
98
|
+
|
99
|
+
Subcase A - When your broker does _not_ require client authentication:
|
100
|
+
|
101
|
+
|
102
|
+
* Expect connection success.
|
103
|
+
* Expect a verify result of 20 becuase the client did not authenticate the
|
104
|
+
server's certificate.
|
105
|
+
|
106
|
+
|
107
|
+
Subcase B - When your broker _does_ require client authentication:
|
108
|
+
|
109
|
+
* Expect connection failure (broker must be sent a valid client certificate).
|
110
|
+
|
111
|
+
### Use Case 2 - No Authentification by broker, authentification by client
|
112
|
+
|
113
|
+
Subcase A - When your broker does _not_ require client authentication:
|
114
|
+
|
115
|
+
* Expect connection success
|
116
|
+
* Expect a verify result of 0 becuase the client did authenticate the
|
117
|
+
server's certificate.
|
118
|
+
|
119
|
+
Subcase B - When your broker _does_ require client authentication:
|
120
|
+
|
121
|
+
* Expect connection failure (broker must be sent a valid client certificate).
|
122
|
+
|
123
|
+
### Use Case 3 - Authentification by broker, no authentification by broker
|
124
|
+
|
125
|
+
Subcase A - When your broker does _not_ require client authentication:
|
126
|
+
|
127
|
+
* Expect connection success
|
128
|
+
* Expect a verify result of 20 becuase the client did not authenticate the
|
129
|
+
server's certificate.
|
130
|
+
|
131
|
+
Subcase B - When your broker _does_ require client authentication:
|
132
|
+
|
133
|
+
* Expect connection success if the server can authenticate the client certificate
|
134
|
+
* Expect a verify result of 20 because the client did not authenticate the
|
135
|
+
server's certificate.
|
136
|
+
|
137
|
+
### Use Case 4 - Authentification by both broker and client
|
138
|
+
|
139
|
+
Subcase A - When your broker does _not_ require client authentication:
|
140
|
+
|
141
|
+
* Expect connection success
|
142
|
+
* Expect a verify result of 0 becuase the client did authenticate the
|
143
|
+
server's certificate.
|
144
|
+
|
145
|
+
Subcase B - When your broker _does_ require client authentication:
|
146
|
+
|
147
|
+
* Expect connection success if the server can authenticate the client certificate
|
148
|
+
* Expect a verify result of 0 because the client did authenticate the
|
149
|
+
server's certificate.
|
150
|
+
|
151
|
+
## Miscellaneous SSL Examples
|
152
|
+
|
153
|
+
The gem provides several other examples of using the built-in SSL
|
154
|
+
functionality. These examples are described below.
|
155
|
+
|
156
|
+
### Override SSL Context Options
|
157
|
+
|
158
|
+
This example is in 'examples/misc/ssl_ctxoptions.rb'.
|
159
|
+
|
160
|
+
The gem provides the capability for the client to supply SSL context options
|
161
|
+
to be used during an SSL connect.
|
162
|
+
|
163
|
+
These options are passed to the gem in the `Stomp::SSLParams` instance.
|
164
|
+
|
165
|
+
These options are then placed by the gem in the `OpenSSL::SSL::SSLContext` instance used during
|
166
|
+
an SSL connect.
|
167
|
+
|
168
|
+
### Specify Parameters When SSL Context Options Are Created
|
169
|
+
|
170
|
+
This example is in 'examples/misc/ssl_newparm.rb'.
|
171
|
+
|
172
|
+
The gem provides the capability of passing parameters to
|
173
|
+
`OpenSSL::SSL::SSLContext.new(..)`.
|
174
|
+
|
175
|
+
These options are passed to the gem in the connect hash used for open/new.
|
176
|
+
|
177
|
+
### Override The Default Cipher List Used BY SSL
|
178
|
+
|
179
|
+
This example is in 'examples/misc/ssl_ucx_default_ciphers.rb'.
|
180
|
+
|
181
|
+
Note: this example is _not_ for use in JRuby.
|
182
|
+
|
183
|
+
The gem allows use of a default list of fairly well known and broker
|
184
|
+
supported ciphers found in `Stomp::DEFAULT_CIPHERS`.
|
185
|
+
|
186
|
+
However, the default list of Ruby ciphers can be requested.
|
187
|
+
|
188
|
+
This is requested when `Stomp::SSLParams` is created by the client using the
|
189
|
+
`:use_ruby_ciphers => true` parameter.
|
@@ -1,8 +1,16 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
3
|
#
|
4
|
-
|
5
|
-
|
4
|
+
if Kernel.respond_to?(:require_relative)
|
5
|
+
require_relative("../ssl_common")
|
6
|
+
require_relative("../../stomp_common")
|
7
|
+
else
|
8
|
+
$LOAD_PATH << File.dirname(__FILE__)
|
9
|
+
require "../ssl_common"
|
10
|
+
require "../../stomp_common"
|
11
|
+
end
|
12
|
+
include SSLCommon
|
13
|
+
include Stomp1xCommon
|
6
14
|
#
|
7
15
|
# == Demo User Control of SSLContext options contents
|
8
16
|
#
|
@@ -14,12 +22,15 @@ require "stomp"
|
|
14
22
|
class ExampleSSLCtxOptions
|
15
23
|
# Initialize.
|
16
24
|
def initialize
|
25
|
+
# It is very likely that you will have to specify your specific port number.
|
26
|
+
# 61611 is currently my AMQ local port number for ssl client auth not required.
|
27
|
+
@port = ENV['STOMP_PORT'] ? ENV['STOMP_PORT'].to_i : 61611
|
17
28
|
end
|
18
29
|
|
19
30
|
# Run example 1
|
20
|
-
def run1
|
31
|
+
def run1()
|
21
32
|
require 'openssl' unless defined?(OpenSSL)
|
22
|
-
puts "
|
33
|
+
puts "run1 method ...."
|
23
34
|
# Define SSL Options to be used. This code is copied from the defaults
|
24
35
|
# in later versions of Ruby V2.x (which has been backported to 1.9.3).
|
25
36
|
#
|
@@ -43,9 +54,8 @@ class ExampleSSLCtxOptions
|
|
43
54
|
ssl_opts = Stomp::SSLParams.new(:ssl_ctxopts => opts, # SSLContext options to set
|
44
55
|
:use_ruby_ciphers => urc,
|
45
56
|
:fsck => true)
|
46
|
-
sport = ENV["STOMP_PORT"].to_i
|
47
57
|
hash = { :hosts => [
|
48
|
-
{:login =>
|
58
|
+
{:login => login(), :passcode => passcode(), :host => host(), :port => @port, :ssl => ssl_opts},
|
49
59
|
],
|
50
60
|
:reliable => false, # YMMV, to test this in a sane manner
|
51
61
|
}
|
@@ -56,11 +66,11 @@ class ExampleSSLCtxOptions
|
|
56
66
|
puts "SSL Verify Result: #{ssl_opts.verify_result}"
|
57
67
|
# puts "SSL Peer Certificate:\n#{ssl_opts.peer_cert}"
|
58
68
|
#
|
59
|
-
c.disconnect
|
69
|
+
c.disconnect()
|
60
70
|
end
|
61
71
|
|
62
72
|
# Run example 2
|
63
|
-
def run2
|
73
|
+
def run2()
|
64
74
|
puts "run2 method ...."
|
65
75
|
#
|
66
76
|
# Connection / Example 2 of 2, gem supplied options.
|
@@ -73,9 +83,8 @@ class ExampleSSLCtxOptions
|
|
73
83
|
ssl_opts = Stomp::SSLParams.new(:ssl_ctxopts => Stomp::Connection::ssl_v2xoptions(),
|
74
84
|
:use_ruby_ciphers => urc,
|
75
85
|
:fsck => true)
|
76
|
-
sport = ENV["STOMP_PORT"].to_i
|
77
86
|
hash = { :hosts => [
|
78
|
-
{:login =>
|
87
|
+
{:login => login(), :passcode => passcode(), :host => host(), :port => @port, :ssl => ssl_opts},
|
79
88
|
],
|
80
89
|
:reliable => false, # YMMV, to test this in a sane manner
|
81
90
|
}
|
@@ -86,11 +95,11 @@ class ExampleSSLCtxOptions
|
|
86
95
|
puts "SSL Verify Result: #{ssl_opts.verify_result}"
|
87
96
|
# puts "SSL Peer Certificate:\n#{ssl_opts.peer_cert}"
|
88
97
|
#
|
89
|
-
c.disconnect
|
98
|
+
c.disconnect()
|
90
99
|
end
|
91
100
|
end
|
92
101
|
#
|
93
|
-
e = ExampleSSLCtxOptions.new
|
94
|
-
e.run1
|
95
|
-
e.run2
|
102
|
+
e = ExampleSSLCtxOptions.new()
|
103
|
+
e.run1()
|
104
|
+
e.run2()
|
96
105
|
|