Skip to content

Commit 83a6b17

Browse files
authored
Merge pull request #4 from jeremyevans/early-initialize-openssl
Initialize OpenSSL early before creating TCPSocket
2 parents 7ba8c5d + 14e09fb commit 83a6b17

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/net/http.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,12 @@ def do_start
972972
private :do_start
973973

974974
def connect
975+
if use_ssl?
976+
# reference early to load OpenSSL before connecting,
977+
# as OpenSSL may take time to load.
978+
@ssl_context = OpenSSL::SSL::SSLContext.new
979+
end
980+
975981
if proxy? then
976982
conn_addr = proxy_address
977983
conn_port = proxy_port
@@ -1019,7 +1025,6 @@ def connect
10191025
end
10201026
end
10211027
end
1022-
@ssl_context = OpenSSL::SSL::SSLContext.new
10231028
@ssl_context.set_params(ssl_parameters)
10241029
@ssl_context.session_cache_mode =
10251030
OpenSSL::SSL::SSLContext::SESSION_CACHE_CLIENT |

0 commit comments

Comments
 (0)