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

Allow for symbols to be used in verify_mode #2011

Merged
merged 1 commit into from Oct 4, 2019
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions History.md
Expand Up @@ -6,6 +6,7 @@
* Bugfixes
* Fix socket activation of systemd (pre-existing) unix binder files (#1842, #1988)
* Deal with multiple calls to bind correctly (#1986, #1994, #2006)
* Accepts symbols for `verify_mode` (#1222)

## 4.2.0 / 2019-09-23

Expand Down
2 changes: 1 addition & 1 deletion lib/puma/dsl.rb
Expand Up @@ -396,7 +396,7 @@ def threads(min, max)
# keystore_pass: password
# }
def ssl_bind(host, port, opts)
verify = opts.fetch(:verify_mode, 'none')
verify = opts.fetch(:verify_mode, 'none').to_s
no_tlsv1 = opts.fetch(:no_tlsv1, 'false')
no_tlsv1_1 = opts.fetch(:no_tlsv1_1, 'false')
ca_additions = "&ca=#{opts[:ca]}" if ['peer', 'force_peer'].include?(verify)
Expand Down
17 changes: 17 additions & 0 deletions test/test_config.rb
Expand Up @@ -97,6 +97,23 @@ def test_ssl_bind_with_cipher_filter
assert ssl_binding.include?("&ssl_cipher_filter=#{cipher_filter}")
end

def test_ssl_bind_with_ca
conf = Puma::Configuration.new do |c|
c.ssl_bind "0.0.0.0", "9292", {
cert: "/path/to/cert",
ca: "/path/to/ca",
key: "/path/to/key",
verify_mode: :peer,
}
end

conf.load

ssl_binding = conf.options[:binds].first
assert_match "ca=/path/to/ca", ssl_binding
assert_match "verify_mode=peer", ssl_binding
end

def test_lowlevel_error_handler_DSL
conf = Puma::Configuration.new do |c|
c.load "test/config/app.rb"
Expand Down