[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
This commit is contained in:
Jeremy Evans 2020-10-27 14:48:25 -07:00 коммит произвёл Hiroshi SHIBATA
Родитель 1229ad0528
Коммит 0296a64450
1 изменённых файлов: 6 добавлений и 1 удалений

Просмотреть файл

@ -972,6 +972,12 @@ module Net #:nodoc:
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:
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 |