-
Notifications
You must be signed in to change notification settings - Fork 183
ssl: separate SSLContext#min_version= and #max_version= #849
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1375,6 +1375,50 @@ def test_minmax_version | |
| } | ||
| end | ||
|
|
||
| def test_minmax_version_system_default | ||
| omit "LibreSSL does not support OPENSSL_CONF" if libressl? | ||
|
|
||
| Tempfile.create("openssl.cnf") { |f| | ||
| f.puts(<<~EOF) | ||
| openssl_conf = default_conf | ||
| [default_conf] | ||
| ssl_conf = ssl_sect | ||
| [ssl_sect] | ||
| system_default = ssl_default_sect | ||
| [ssl_default_sect] | ||
| MaxProtocol = TLSv1.2 | ||
| EOF | ||
| f.close | ||
|
|
||
| start_server(ignore_listener_error: true) do |port| | ||
| assert_separately([{ "OPENSSL_CONF" => f.path }, "-ropenssl", "-", port.to_s], <<~"end;") | ||
| sock = TCPSocket.new("127.0.0.1", ARGV[0].to_i) | ||
| ctx = OpenSSL::SSL::SSLContext.new | ||
| ctx.min_version = OpenSSL::SSL::TLS1_2_VERSION | ||
| ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx) | ||
| ssl.sync_close = true | ||
| ssl.connect | ||
| assert_equal("TLSv1.2", ssl.ssl_version) | ||
| ssl.puts("abc"); assert_equal("abc\n", ssl.gets) | ||
| ssl.close | ||
| end; | ||
|
|
||
| assert_separately([{ "OPENSSL_CONF" => f.path }, "-ropenssl", "-", port.to_s], <<~"end;") | ||
| sock = TCPSocket.new("127.0.0.1", ARGV[0].to_i) | ||
| ctx = OpenSSL::SSL::SSLContext.new | ||
| ctx.min_version = OpenSSL::SSL::TLS1_2_VERSION | ||
| ctx.max_version = nil | ||
| ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx) | ||
| ssl.sync_close = true | ||
| ssl.connect | ||
| assert_equal("TLSv1.3", ssl.ssl_version) | ||
| ssl.puts("abc"); assert_equal("abc\n", ssl.gets) | ||
| ssl.close | ||
| end; | ||
| end | ||
| } | ||
| end | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test looks great! I want to see you add one more test here with the following conditions to test
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I agree an additional test case would be useful.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. Thanks for your explanation. So, I assume that if we execute the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
All right. In the additional test, I can see the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is correct. Since protocol version negotiation chooses the highest common version, the difference isn't observable. It would negotiate TLS 1.3 whether you have I just pushed a new commit with updated tests. In the latter block,
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All right. The tests look good to me!
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for the review! |
||
| def test_options_disable_versions | ||
| # It's recommended to use SSLContext#{min,max}_version= instead in real | ||
| # applications. The purpose of this test case is to check that SSL options | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.