aboutsummaryrefslogtreecommitdiffstats
path: root/test/openssl
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2020-07-18 17:14:55 +0900
committerKazuki Yamaguchi <k@rhe.jp>2021-03-16 19:16:11 +0900
commit81325db5f8bcd8c3e964ff6285792c2cade29b2c (patch)
tree1e09dfc0b22aa7c59d389286da34c9507dfdd4ff /test/openssl
parent3b43e3fa10b160fd86a51b6e09ab157ca7be723a (diff)
downloadruby-81325db5f8bcd8c3e964ff6285792c2cade29b2c.tar.gz
[ruby/openssl] ssl: initialize verify_mode and verify_hostname with default values
SSLContext's verify_mode expects an SSL_VERIFY_* constant (an integer) and verify_hostname expects either true or false. However, they are set to nil after calling OpenSSL::SSL::SSLContext.new, which is surprising. Set a proper value to them by default: verify_mode is set to OpenSSL::SSL::VERIFY_NONE and verify_hostname is set to false by default. Note that this does not change the default behavior. The certificate verification was never performed unless verify_mode is set to OpenSSL::SSL::VERIFY_PEER by a user. The same applies to verify_hostname. https://github.com/ruby/openssl/commit/87d869352c
Diffstat (limited to 'test/openssl')
-rw-r--r--test/openssl/test_ssl.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/openssl/test_ssl.rb b/test/openssl/test_ssl.rb
index 4015b050d2..59c94932c9 100644
--- a/test/openssl/test_ssl.rb
+++ b/test/openssl/test_ssl.rb
@@ -246,6 +246,11 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase
end
end
+ def test_verify_mode_default
+ ctx = OpenSSL::SSL::SSLContext.new
+ assert_equal OpenSSL::SSL::VERIFY_NONE, ctx.verify_mode
+ end
+
def test_verify_mode_server_cert
start_server(ignore_listener_error: true) { |port|
populated_store = OpenSSL::X509::Store.new
@@ -919,6 +924,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase
start_server(ctx_proc: ctx_proc, ignore_listener_error: true) do |port|
ctx = OpenSSL::SSL::SSLContext.new
+ assert_equal false, ctx.verify_hostname
ctx.verify_hostname = true
ctx.cert_store = OpenSSL::X509::Store.new
ctx.cert_store.add_cert(@ca_cert)