stomp 1.3.3 → 1.3.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,17 @@
1
+ == 1.3.4 20141202
2
+
3
+ * Change :start_timeout default to 0 (might break some clients) (#98).
4
+ * Allow user set of SSLContext options (#105).
5
+ * Allow user set of parm in SSLContext.new(parm) (#105).
6
+
7
+ == 1.3.3 20140810
8
+
9
+ * Do not attempt to write empty message bodies.
10
+ * Explicity close ssl socket on connection timeout.
11
+ * Fix incorrect behavior for empty header keys (#93)
12
+ * Do not override explicit :reliable => false.
13
+ * Fix client fail-over fails (#98)
14
+
1
15
  == 1.3.2 20131208
2
16
 
3
17
  * Anon tests assigned unique class name.
data/README.rdoc CHANGED
@@ -12,6 +12,8 @@ An implementation of the Stomp protocol for Ruby. See:
12
12
 
13
13
  See _CHANGELOG.rdoc_ for details.
14
14
 
15
+ * Gem version 1.3.4. Miscellaneous fixes, see CHANGELOG.rdoc for details.
16
+ * Gem version 1.3.3. Miscellaneous fixes, see CHANGELOG.rdoc for details.
15
17
  * Gem version 1.3.2. Miscellaneous fixes, see changelog for details.
16
18
  * Gem version 1.3.1. Bugfix for logging.
17
19
  * Gem version 1.3.0. Added ERROR frame raising as exception, added anonymous connections, miscellaneous other fixes.
@@ -67,7 +69,8 @@ See _CHANGELOG.rdoc_ for details.
67
69
  # correct for your environment, expect unnecessary fail overs
68
70
  :connread_timeout => 0, # Timeout during CONNECT for read of CONNECTED/ERROR, secs
69
71
  :tcp_nodelay => true, # Turns on the TCP_NODELAY socket option; disables Nagle's algorithm
70
- :start_timeout => 10, # Timeout around Stomp::Client initialization
72
+ :start_timeout => 0, # Timeout around Stomp::Client initialization
73
+ :sslctx_newparm => nil, # Param for SSLContext.new
71
74
  }
72
75
 
73
76
  # for client
@@ -0,0 +1,96 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ #
4
+ require "rubygems"
5
+ require "stomp"
6
+ #
7
+ # == Demo User Control of SSLContext options contents
8
+ #
9
+ # Roughly based on example ssl_uc1.rb.
10
+ # See comments in that example for more detail.
11
+ #
12
+ # Not tested with jruby. YMMV.
13
+ #
14
+ class ExampleSSLCtxOptions
15
+ # Initialize.
16
+ def initialize
17
+ end
18
+
19
+ # Run example 1
20
+ def run1
21
+ require 'openssl' unless defined?(OpenSSL)
22
+ puts "run method ...."
23
+ # Define SSL Options to be used. This code is copied from the defaults
24
+ # in later versions of Ruby V2.x (which has been backported to 1.9.3).
25
+ #
26
+ # Connection / Example 1 of 2, user supplied options.
27
+ #
28
+
29
+ # Build SSL Options per user requirements: this is just one
30
+ # particular/possible example of setting SSL context options.
31
+ opts = OpenSSL::SSL::OP_ALL
32
+ # Perhaps. If you need/want any of these you will know it.
33
+ # This is exactly what is done in later versions of Ruby 2.x (also has
34
+ # been backported by Ruby team to later versions of 1.9.3).
35
+ opts &= ~OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS if defined?(OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS)
36
+ opts |= OpenSSL::SSL::OP_NO_COMPRESSION if defined?(OpenSSL::SSL::OP_NO_COMPRESSION)
37
+ opts |= OpenSSL::SSL::OP_NO_SSLv2 if defined?(OpenSSL::SSL::OP_NO_SSLv2)
38
+ opts |= OpenSSL::SSL::OP_NO_SSLv3 if defined?(OpenSSL::SSL::OP_NO_SSLv3)
39
+
40
+ urc = defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/ ? true : false
41
+
42
+ # Pass options to SSLParams constructor.
43
+ ssl_opts = Stomp::SSLParams.new(:ssl_ctxopts => opts, # SSLContext options to set
44
+ :use_ruby_ciphers => urc,
45
+ :fsck => true)
46
+ sport = ENV["STOMP_PORT"].to_i
47
+ hash = { :hosts => [
48
+ {:login => 'guest', :passcode => 'guest', :host => 'localhost', :port => sport, :ssl => ssl_opts},
49
+ ],
50
+ :reliable => false, # YMMV, to test this in a sane manner
51
+ }
52
+ #
53
+ puts "Connect starts, SSLContext Options Set: #{opts}"
54
+ c = Stomp::Connection.new(hash)
55
+ puts "Connect completed"
56
+ puts "SSL Verify Result: #{ssl_opts.verify_result}"
57
+ # puts "SSL Peer Certificate:\n#{ssl_opts.peer_cert}"
58
+ #
59
+ c.disconnect
60
+ end
61
+
62
+ # Run example 2
63
+ def run2
64
+ puts "run2 method ...."
65
+ #
66
+ # Connection / Example 2 of 2, gem supplied options.
67
+ #
68
+
69
+ urc = defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/ ? true : false
70
+
71
+ # Use gem method to define SSL options. Exactly the same as the
72
+ # options used in Example 1 above.
73
+ ssl_opts = Stomp::SSLParams.new(:ssl_ctxopts => Stomp::Connection::ssl_v2xoptions(),
74
+ :use_ruby_ciphers => urc,
75
+ :fsck => true)
76
+ sport = ENV["STOMP_PORT"].to_i
77
+ hash = { :hosts => [
78
+ {:login => 'guest', :passcode => 'guest', :host => 'localhost', :port => sport, :ssl => ssl_opts},
79
+ ],
80
+ :reliable => false, # YMMV, to test this in a sane manner
81
+ }
82
+ #
83
+ puts "Connect starts, SSLContext Options Set: #{Stomp::Connection::ssl_v2xoptions()}"
84
+ c = Stomp::Connection.new(hash)
85
+ puts "Connect completed"
86
+ puts "SSL Verify Result: #{ssl_opts.verify_result}"
87
+ # puts "SSL Peer Certificate:\n#{ssl_opts.peer_cert}"
88
+ #
89
+ c.disconnect
90
+ end
91
+ end
92
+ #
93
+ e = ExampleSSLCtxOptions.new
94
+ e.run1
95
+ e.run2
96
+
@@ -0,0 +1,43 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ #
4
+ # Reference: https://github.com/stompgem/stomp/wiki/extended-ssl-overview
5
+ #
6
+ require "rubygems"
7
+ require "stomp"
8
+ #
9
+ # == Demo override of SSLContext.new parameters.
10
+ #
11
+ # Based roughly on example ssl_uc1.rb.
12
+ #
13
+ #
14
+ class ExampleSSLNewParm
15
+ # Initialize.
16
+ def initialize
17
+ end
18
+ # Run example.
19
+ def run
20
+ ssl_opts = Stomp::SSLParams.new
21
+ hash = { :hosts => [
22
+ {:login => 'guest', :passcode => 'guest', :host => 'localhost', :port => 61612, :ssl => ssl_opts},
23
+ ],
24
+ :reliable => false, # YMMV, to test this in a sane manner
25
+ :sslctx_newparm => :SSLv2, # An example should you:
26
+ # a) Actually want SSLv2 *AND*
27
+ # b) Your Ruby version supports SSLv2 *AND*
28
+ # c) Your broker supports and allows SSLv2
29
+ }
30
+ #
31
+ puts "Connect starts, SSL Use Case 1"
32
+ c = Stomp::Connection.new(hash)
33
+ puts "Connect completed"
34
+ puts "SSL Verify Result: #{ssl_opts.verify_result}"
35
+ # puts "SSL Peer Certificate:\n#{ssl_opts.peer_cert}"
36
+ #
37
+ c.disconnect
38
+ end
39
+ end
40
+ #
41
+ e = ExampleSSLNewParm.new
42
+ e.run
43
+
data/examples/ssl_uc2.rb CHANGED
@@ -30,8 +30,7 @@ class ExampleSSL2
30
30
  ts_flist << "/home/gmallard/sslwork/2013/TestCA.crt"
31
31
 
32
32
  ssl_opts = Stomp::SSLParams.new(:ts_files => ts_flist.join(","),
33
- :fsck => true,
34
- )
33
+ :fsck => true)
35
34
  #
36
35
  hash = { :hosts => [
37
36
  {:login => 'guest', :passcode => 'guest', :host => 'localhost', :port => 61612, :ssl => ssl_opts},
data/lib/client/utils.rb CHANGED
@@ -107,8 +107,7 @@ module Stomp
107
107
  if @parameters[:reliable] && @start_timeout > 0
108
108
  warn "WARN detected :reliable == true and :start_timeout > 0"
109
109
  warn "WARN this may cause incorrect fail-over behavior"
110
- warn "WARN use :start_timeout => 0 to correct"
111
- warn "WARN !! :start_timeout default will change to 0 in the next release"
110
+ warn "WARN use :start_timeout => 0 to correct fail-over behavior"
112
111
  end
113
112
  end
114
113
 
@@ -209,7 +209,7 @@ module Stomp
209
209
  def open_ssl_socket()
210
210
  require 'openssl' unless defined?(OpenSSL)
211
211
  begin # Any raised SSL exceptions
212
- ctx = OpenSSL::SSL::SSLContext.new
212
+ ctx = @sslctx_newparm ? OpenSSL::SSL::SSLContext.new(@sslctx_newparm) : OpenSSL::SSL::SSLContext.new
213
213
  ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE # Assume for now
214
214
  #
215
215
  # Note: if a client uses :ssl => true this would result in the gem using
@@ -275,6 +275,13 @@ module Stomp
275
275
  ctx.ciphers = Stomp::DEFAULT_CIPHERS # Just use Stomp defaults
276
276
  end
277
277
  end
278
+
279
+ # Set SSLContext Options if user asks for it in Stomp::SSLParams
280
+ # and SSL supports it.
281
+ if @ssl.ssl_ctxopts && ctx.respond_to?(:options=)
282
+ ctx.options = @ssl.ssl_ctxopts
283
+ end
284
+
278
285
  end
279
286
 
280
287
  #
@@ -178,7 +178,8 @@ module Stomp
178
178
  :fast_hbs_adjust => 0.0,
179
179
  :connread_timeout => 0,
180
180
  :tcp_nodelay => true,
181
- :start_timeout => 10,
181
+ :start_timeout => 0,
182
+ :sslctx_newparm => nil,
182
183
  }
183
184
 
184
185
  res_params = default_params.merge(params)
data/lib/stomp/client.rb CHANGED
@@ -51,7 +51,8 @@ module Stomp
51
51
  # :fast_hbs_adjust => 0.0,
52
52
  # :connread_timeout => 0,
53
53
  # :tcp_nodelay => true,
54
- # :start_timeout => 10,
54
+ # :start_timeout => 0,
55
+ # :sslctx_newparm => nil,
55
56
  # }
56
57
  #
57
58
  # e.g. c = Stomp::Client.new(hash)
@@ -82,7 +83,7 @@ module Stomp
82
83
  parse_positional_params(login, passcode, host, port, reliable)
83
84
 
84
85
  @logger = @parameters[:logger] ||= Stomp::NullLogger.new
85
- @start_timeout = @parameters[:start_timeout] || 10.0
86
+ @start_timeout = @parameters[:start_timeout] || 0
86
87
  check_arguments!()
87
88
 
88
89
  begin
@@ -46,6 +46,18 @@ module Stomp
46
46
  ssl ? 61612 : 61613
47
47
  end
48
48
 
49
+ # SSL Helper
50
+ def self.ssl_v2xoptions()
51
+ require 'openssl' unless defined?(OpenSSL)
52
+ # Mimic code in later versions of Ruby 2.x (and backported to later
53
+ # versions of 1.9.3).
54
+ opts = OpenSSL::SSL::OP_ALL
55
+ opts &= ~OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS if defined?(OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS)
56
+ opts |= OpenSSL::SSL::OP_NO_COMPRESSION if defined?(OpenSSL::SSL::OP_NO_COMPRESSION)
57
+ opts |= OpenSSL::SSL::OP_NO_SSLv2 if defined?(OpenSSL::SSL::OP_NO_SSLv2)
58
+ opts |= OpenSSL::SSL::OP_NO_SSLv3 if defined?(OpenSSL::SSL::OP_NO_SSLv3)
59
+ end
60
+
49
61
  # A new Connection object can be initialized using two forms:
50
62
  #
51
63
  # Hash (this is the recommended Connection initialization method):
@@ -76,7 +88,8 @@ module Stomp
76
88
  # :fast_hbs_adjust => 0.0,
77
89
  # :connread_timeout => 0,
78
90
  # :tcp_nodelay => true,
79
- # :start_timeout => 10,
91
+ # :start_timeout => 0,
92
+ # :sslctx_newparm => nil,
80
93
  # }
81
94
  #
82
95
  # e.g. c = Stomp::Connection.new(hash)
@@ -126,7 +139,8 @@ module Stomp
126
139
  @fast_hbs_adjust = 0.0 # Fast heartbeat senders sleep adjustment
127
140
  @connread_timeout = 0 # Connect read CONNECTED/ERROR timeout
128
141
  @tcp_nodelay = true # Disable Nagle
129
- @start_timeout = 10 # Client only, startup timeout
142
+ @start_timeout = 0 # Client only, startup timeout
143
+ @sslctx_newparm = nil # SSLContext.new paramater
130
144
  warn "login looks like a URL, do you have the correct parameters?" if @login =~ /:\/\//
131
145
  end
132
146
 
@@ -163,6 +177,7 @@ module Stomp
163
177
  @max_hbrlck_fails = @parameters[:max_hbrlck_fails]
164
178
  @fast_hbs_adjust = @parameters[:fast_hbs_adjust]
165
179
  @connread_timeout = @parameters[:connread_timeout]
180
+ @sslctx_newparm = @parameters[:sslctx_newparm]
166
181
  #
167
182
  # Try to support Ruby 1.9.x and 2.x ssl.
168
183
  unless defined?(RSpec)
@@ -41,6 +41,9 @@ module Stomp
41
41
  # Client wants file existance check on initialize. true/value or false/nil.
42
42
  attr_reader :fsck #
43
43
 
44
+ # SSLContext options.
45
+ attr_reader :ssl_ctxopts #
46
+
44
47
  # initialize returns a valid instance of SSLParams or raises an error.
45
48
  def initialize(opts={})
46
49
 
@@ -76,6 +79,8 @@ module Stomp
76
79
  end
77
80
  end
78
81
  end
82
+ # SSLContext options. See example: ssl_ctxoptions.rb.
83
+ @ssl_ctxopts = opts[:ssl_ctxopts] # nil or options to set
79
84
  end
80
85
 
81
86
  end # of class SSLParams
data/lib/stomp/version.rb CHANGED
@@ -6,7 +6,7 @@ module Stomp
6
6
  module Version #:nodoc: all
7
7
  MAJOR = 1
8
8
  MINOR = 3
9
- PATCH = 3
9
+ PATCH = 4
10
10
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
11
11
  end
12
12
  end
data/spec/client_spec.rb CHANGED
@@ -77,18 +77,6 @@ describe Stomp::Client do
77
77
 
78
78
  describe "(created with invalid params)" do
79
79
 
80
- it "should return ArgumentError if host is nil" do
81
- lambda {
82
- @client = Stomp::Client.new('login', 'passcode', nil)
83
- }.should raise_error
84
- end
85
-
86
- it "should return ArgumentError if host is empty" do
87
- lambda {
88
- @client = Stomp::Client.new('login', 'passcode', '')
89
- }.should raise_error
90
- end
91
-
92
80
  it "should return ArgumentError if port is nil" do
93
81
  lambda {
94
82
  @client = Stomp::Client.new('login', 'passcode', 'localhost', nil)
@@ -30,7 +30,8 @@ describe Stomp::Connection do
30
30
  :fast_hbs_adjust => 0.0,
31
31
  :connread_timeout => 0,
32
32
  :tcp_nodelay => true,
33
- :start_timeout => 10,
33
+ :start_timeout => 0,
34
+ :sslctx_newparm => nil,
34
35
  }
35
36
 
36
37
  #POG:
@@ -101,7 +102,9 @@ describe Stomp::Connection do
101
102
  :fastHbsAdjust => 0.0,
102
103
  :connreadTimeout => 0,
103
104
  :tcpNodelay => true,
104
- :startTimeout => 10,
105
+ :startTimeout => 0,
106
+ :sslctxNewparm => nil,
107
+
105
108
  }
106
109
 
107
110
  @connection = Stomp::Connection.new(used_hash)
@@ -358,7 +361,8 @@ describe Stomp::Connection do
358
361
  :fast_hbs_adjust => 0.0,
359
362
  :connread_timeout => 0,
360
363
  :tcp_nodelay => true,
361
- :start_timeout => 10,
364
+ :start_timeout => 0,
365
+ :sslctx_newparm => nil,
362
366
  }
363
367
 
364
368
  used_hash = {
@@ -401,6 +405,7 @@ describe Stomp::Connection do
401
405
  :connread_timeout => 42,
402
406
  :tcp_nodelay => false,
403
407
  :start_timeout => 6,
408
+ :sslctx_newparm=>:TLSv1,
404
409
  }
405
410
 
406
411
  @connection = Stomp::Connection.new(used_hash)
data/stomp.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{stomp}
8
- s.version = "1.3.3"
8
+ s.version = "1.3.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Brian McCallister", "Marius Mathiesen", "Thiago Morello", "Guy M. Allard"]
12
- s.date = %q{2014-08-10}
12
+ s.date = %q{2014-12-02}
13
13
  s.description = %q{Ruby client for the Stomp messaging protocol. Note that this gem is no longer supported on rubyforge.}
14
14
  s.email = ["brianm@apache.org", "marius@stones.com", "morellon@gmail.com", "allard.guy.m@gmail.com"]
15
15
  s.executables = ["catstomp", "stompcat"]
@@ -31,6 +31,8 @@ Gem::Specification.new do |s|
31
31
  "examples/publisher.rb",
32
32
  "examples/put11conn_ex1.rb",
33
33
  "examples/putget11_rh1.rb",
34
+ "examples/ssl_ctxoptions.rb",
35
+ "examples/ssl_newparm.rb",
34
36
  "examples/ssl_uc1.rb",
35
37
  "examples/ssl_uc1_ciphers.rb",
36
38
  "examples/ssl_uc2.rb",
@@ -92,6 +94,8 @@ Gem::Specification.new do |s|
92
94
  "examples/publisher.rb",
93
95
  "examples/put11conn_ex1.rb",
94
96
  "examples/putget11_rh1.rb",
97
+ "examples/ssl_ctxoptions.rb",
98
+ "examples/ssl_newparm.rb",
95
99
  "examples/ssl_uc1.rb",
96
100
  "examples/ssl_uc1_ciphers.rb",
97
101
  "examples/ssl_uc2.rb",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stomp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 3
9
- - 3
10
- version: 1.3.3
9
+ - 4
10
+ version: 1.3.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brian McCallister
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2014-08-10 00:00:00 -04:00
21
+ date: 2014-12-02 00:00:00 -05:00
22
22
  default_executable:
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
@@ -65,6 +65,8 @@ extra_rdoc_files:
65
65
  - examples/publisher.rb
66
66
  - examples/put11conn_ex1.rb
67
67
  - examples/putget11_rh1.rb
68
+ - examples/ssl_ctxoptions.rb
69
+ - examples/ssl_newparm.rb
68
70
  - examples/ssl_uc1.rb
69
71
  - examples/ssl_uc1_ciphers.rb
70
72
  - examples/ssl_uc2.rb
@@ -125,6 +127,8 @@ files:
125
127
  - examples/publisher.rb
126
128
  - examples/put11conn_ex1.rb
127
129
  - examples/putget11_rh1.rb
130
+ - examples/ssl_ctxoptions.rb
131
+ - examples/ssl_newparm.rb
128
132
  - examples/ssl_uc1.rb
129
133
  - examples/ssl_uc1_ciphers.rb
130
134
  - examples/ssl_uc2.rb