ruby-changes:66005
From: Jeremy <ko1@a...>
Date: Wed, 28 Apr 2021 11:04:18 +0900 (JST)
Subject: [ruby-changes:66005] 0296a64450 (master): [ruby/net-http] Initialize OpenSSL early before creating TCPSocket
https://git.ruby-lang.org/ruby.git/commit/?id=0296a64450 From 0296a64450019bf0d2c5b342a1d988ca3ace3d66 Mon Sep 17 00:00:00 2001 From: Jeremy Evans <code@j...> Date: Tue, 27 Oct 2020 14:48:25 -0700 Subject: [ruby/net-http] Initialize OpenSSL early before creating TCPSocket OpenSSL make take some time to initialize, and it would be best to take that time before connecting instead of after. From joshc on Redmine. Fixes Ruby Bug #9459 https://github.com/ruby/net-http/commit/14e09fba24 --- lib/net/http.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/net/http.rb b/lib/net/http.rb index 9351606..862f88d 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -972,6 +972,12 @@ module Net #:nodoc: https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L972 private :do_start def connect + if use_ssl? + # reference early to load OpenSSL before connecting, + # as OpenSSL may take time to load. + @ssl_context = OpenSSL::SSL::SSLContext.new + end + if proxy? then conn_addr = proxy_address conn_port = proxy_port @@ -1018,7 +1024,6 @@ module Net #:nodoc: https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L1024 end end end - @ssl_context = OpenSSL::SSL::SSLContext.new @ssl_context.set_params(ssl_parameters) @ssl_context.session_cache_mode = OpenSSL::SSL::SSLContext::SESSION_CACHE_CLIENT | -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/