Skip to content

Commit fd87a8a

Browse files
committed
merge revision(s) r48563,r46261,r48581: [Backport ruby#10533]
* lib/net/http.rb: Do not attempt SSL session resumption when the session is expired. [Bug ruby#10533] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent e6e559c commit fd87a8a

4 files changed

Lines changed: 43 additions & 2 deletions

File tree

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Wed Feb 18 00:27:57 2015 Eric Hodel <drbrain@segment7.net>
2+
3+
* lib/net/http.rb: Do not attempt SSL session resumption when the
4+
session is expired. [Bug #10533]
5+
16
Wed Feb 18 00:20:36 2015 Eric Wong <e@80x24.org>
27

38
* vm_eval.c (rb_yield_splat): add missing GC guard

lib/net/http.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,10 @@ def connect
914914
@socket.write(buf)
915915
HTTPResponse.read_new(@socket).value
916916
end
917-
s.session = @ssl_session if @ssl_session
917+
if @ssl_session and
918+
Time.now < @ssl_session.time + @ssl_session.timeout
919+
s.session = @ssl_session if @ssl_session
920+
end
918921
# Server Name Indication (SNI) RFC 3546
919922
s.hostname = @address if s.respond_to? :hostname=
920923
Timeout.timeout(@open_timeout, Net::OpenTimeout) { s.connect }

test/net/http/test_https.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,45 @@ def test_session_reuse
7373
http.get("/")
7474
http.finish # three times due to possible bug in OpenSSL 0.9.8
7575

76+
sid = http.instance_variable_get(:@ssl_session).id
77+
7678
http.start
7779
http.get("/")
7880

7981
socket = http.instance_variable_get(:@socket).io
8082

8183
assert socket.session_reused?
84+
85+
assert_equal sid, http.instance_variable_get(:@ssl_session).id
86+
87+
http.finish
88+
rescue SystemCallError
89+
skip $!
90+
end
91+
92+
def test_session_reuse_but_expire
93+
http = Net::HTTP.new("localhost", config("port"))
94+
http.use_ssl = true
95+
http.verify_callback = Proc.new do |preverify_ok, store_ctx|
96+
store_ctx.current_cert.to_der == config('ssl_certificate').to_der
97+
end
98+
99+
http.ssl_timeout = -1
100+
http.start
101+
http.get("/")
102+
http.finish
103+
104+
sid = http.instance_variable_get(:@ssl_session).id
105+
106+
http.start
107+
http.get("/")
108+
109+
socket = http.instance_variable_get(:@socket).io
110+
assert_equal false, socket.session_reused?
111+
112+
assert_not_equal sid, http.instance_variable_get(:@ssl_session).id
113+
114+
http.finish
82115
rescue SystemCallError
83116
skip $!
84117
end

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.1.5"
22
#define RUBY_RELEASE_DATE "2015-02-18"
3-
#define RUBY_PATCHLEVEL 296
3+
#define RUBY_PATCHLEVEL 297
44

55
#define RUBY_RELEASE_YEAR 2015
66
#define RUBY_RELEASE_MONTH 2

0 commit comments

Comments
 (0)