Project

General

Profile

Feature #5341 » net.http.rb.ssl_session_reuse.patch

Create a new ssl_context for each call to #connect - drbrain (Eric Hodel), 11/23/2011 09:28 AM

View differences:

lib/net/http.rb (working copy)
@debug_output = nil
@use_ssl = false
@ssl_context = nil
@ssl_session = nil
@enable_post_connection_check = true
@compression = nil
@sspi_enabled = false
......
@ssl_context = OpenSSL::SSL::SSLContext.new
@ssl_context.set_params(ssl_parameters)
s = OpenSSL::SSL::SSLSocket.new(s, @ssl_context)
s.session = @ssl_session if @ssl_session
s.sync_close = true
end
@socket = BufferedIO.new(s)
......
if @ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE
s.post_connection_check(@address)
end
@ssl_session = s.session
rescue => exception
D "Conn close because of connect error #{exception}"
@socket.close if @socket and not @socket.closed?
test/net/http/test_https.rb (working copy)
skip $!
end
def test_session_reuse
http = Net::HTTP.new("localhost", config("port"))
http.use_ssl = true
http.verify_callback = Proc.new do |preverify_ok, store_ctx|
store_ctx.current_cert.to_der == config('ssl_certificate').to_der
end
http.start
http.get("/")
http.finish
http.start
http.get("/")
http.finish # three times due to possible bug in OpenSSL 0.9.8
http.start
http.get("/")
socket = http.instance_variable_get(:@socket).io
assert socket.session_reused?
end
if ENV["RUBY_OPENSSL_TEST_ALL"]
def test_verify
http = Net::HTTP.new("ssl.netlab.jp", 443)
(2-2/3)