From cf73cf5981802f2bcc30aba07914acf4286cda5a Mon Sep 17 00:00:00 2001 From: Karol Bucek Date: Wed, 20 Apr 2022 06:01:02 +0200 Subject: [ruby/net-http] Feature detect to make net/http usable with JRuby Handle missing session_new_cb= and do not call session_cache_mode=, as JRuby SSL does not support these methods. https://github.com/ruby/net-http/commit/3237ef4d8c --- lib/net/http.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/net/http.rb b/lib/net/http.rb index dc8ed051f0..dd64a2d11e 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -1051,10 +1051,14 @@ module Net #:nodoc: end end @ssl_context.set_params(ssl_parameters) - @ssl_context.session_cache_mode = - OpenSSL::SSL::SSLContext::SESSION_CACHE_CLIENT | - OpenSSL::SSL::SSLContext::SESSION_CACHE_NO_INTERNAL_STORE - @ssl_context.session_new_cb = proc {|sock, sess| @ssl_session = sess } + unless @ssl_context.session_cache_mode.nil? # a dummy method on JRuby + @ssl_context.session_cache_mode = + OpenSSL::SSL::SSLContext::SESSION_CACHE_CLIENT | + OpenSSL::SSL::SSLContext::SESSION_CACHE_NO_INTERNAL_STORE + end + if @ssl_context.respond_to?(:session_new_cb) # not implemented under JRuby + @ssl_context.session_new_cb = proc {|sock, sess| @ssl_session = sess } + end # Still do the post_connection_check below even if connecting # to IP address -- cgit v1.2.3