Skip to content

Commit

Permalink
Merge pull request #38 from headius/no_session_cache_on_jruby
Browse files Browse the repository at this point in the history
Don't use OpenSSL session cache on JRuby
  • Loading branch information
hsbt authored Jun 25, 2024
2 parents 48dac96 + 3b1c84b commit 1215c30
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions lib/net/ftp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,15 @@ def initialize(host = nil, user_or_options = {}, passwd = nil, acct = nil)
if defined?(VerifyCallbackProc)
@ssl_context.verify_callback = VerifyCallbackProc
end
@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 }

# jruby-openssl does not support session caching
unless RUBY_ENGINE == "jruby"
@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 }
end

@ssl_session = nil
if options[:private_data_connection].nil?
@private_data_connection = true
Expand Down
2 changes: 1 addition & 1 deletion test/net/ftp/test_ftp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1953,7 +1953,7 @@ def test_active_private_data_connection
assert_equal(nil, commands.shift)
# FIXME: The new_session_cb is known broken for clients in OpenSSL 1.1.0h.
# See https://github.com/openssl/openssl/pull/5967 for details.
if OpenSSL::OPENSSL_LIBRARY_VERSION !~ /OpenSSL 1.1.0h|LibreSSL/
if RUBY_ENGINE != "jruby" && OpenSSL::OPENSSL_LIBRARY_VERSION !~ /OpenSSL 1.1.0h|LibreSSL/
assert_equal(true, session_reused_for_data_connection)
end
ensure
Expand Down

0 comments on commit 1215c30

Please sign in to comment.