Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestPumaServerSSLClient - share Context [changelog skip] #2364

Merged
merged 1 commit into from Sep 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 10 additions & 8 deletions test/test_puma_server_ssl.rb
Expand Up @@ -255,13 +255,8 @@ class TestPumaServerSSLClient < Minitest::Test

CERT_PATH = File.expand_path "../examples/puma/client-certs", __dir__

def assert_ssl_client_error_match(error, subject=nil, &blk)
host = "localhost"
port = 0

app = lambda { |env| [200, {}, [env['rack.url_scheme']]] }

ctx = Puma::MiniSSL::Context.new
# Context can be shared, may help with JRuby
CTX = Puma::MiniSSL::Context.new.tap { |ctx|
if Puma.jruby?
ctx.keystore = "#{CERT_PATH}/keystore.jks"
ctx.keystore_pass = 'jruby_puma'
Expand All @@ -271,10 +266,17 @@ def assert_ssl_client_error_match(error, subject=nil, &blk)
ctx.ca = "#{CERT_PATH}/ca.crt"
end
ctx.verify_mode = Puma::MiniSSL::VERIFY_PEER | Puma::MiniSSL::VERIFY_FAIL_IF_NO_PEER_CERT
}

def assert_ssl_client_error_match(error, subject=nil, &blk)
host = "localhost"
port = 0

app = lambda { |env| [200, {}, [env['rack.url_scheme']]] }

events = SSLEventsHelper.new STDOUT, STDERR
server = Puma::Server.new app, events
server.add_ssl_listener host, port, ctx
server.add_ssl_listener host, port, CTX
host_addrs = server.binder.ios.map { |io| io.to_io.addr[2] }
server.run

Expand Down