[ruby/openssl] ssl: fix test case test_npn_advertised_protocol_too_long

The list of NPN protocols is validated in SSLContext#setup.

The assert_handshake_error is misleading. The client is unable to start
a handshake at all because the server is not running.

https://github.com/ruby/openssl/commit/e8db6ffd9e
This commit is contained in:
Kazuki Yamaguchi 2025-02-06 23:55:49 +09:00 committed by git
parent 1f4fc2e608
commit a8b36314ec

View File

@ -1639,12 +1639,11 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase
def test_npn_advertised_protocol_too_long
return unless OpenSSL::SSL::SSLContext.method_defined?(:npn_select_cb)
ctx_proc = Proc.new { |ctx| ctx.npn_protocols = ["a" * 256] }
start_server_version(:TLSv1_2, ctx_proc) { |port|
ctx = OpenSSL::SSL::SSLContext.new
ctx.npn_select_cb = -> (protocols) { protocols.first }
assert_handshake_error { server_connect(port, ctx) }
}
ctx = OpenSSL::SSL::SSLContext.new
assert_raise(OpenSSL::SSL::SSLError) do
ctx.npn_protocols = ["a" * 256]
ctx.setup
end
end
def test_npn_selected_protocol_too_long