diff options
author | Yusuke Endoh <[email protected]> | 2019-06-05 21:07:27 +0900 |
---|---|---|
committer | Yusuke Endoh <[email protected]> | 2019-06-06 14:20:58 +0900 |
commit | 1e54903684aa3c9ea3fe54520157846a1b1f07be (patch) | |
tree | 72b7ea26c1b0f7026bdbef83ccd64041d04d583f /test/openssl/test_pair.rb | |
parent | d046fe926273d0137f2d5cdf2dedfcfeeb98189b (diff) |
test/openssl: Support OpenSSL 1.1.1
OpenSSL 1.1.1 rejects some shorter keys, which caused some failures of
`make test-all TESTS=openssl`.
https://rubyci.org/logs/rubyci.s3.amazonaws.com/debian/ruby-master/log/20190606T003005Z.fail.html.gz
This change merges 6bbc31ddd1 and 63fb3a36d1 in
https://github.com/ruby/openssl.
Reference: https://github.com/ruby/openssl/pull/217
Diffstat (limited to 'test/openssl/test_pair.rb')
-rw-r--r-- | test/openssl/test_pair.rb | 59 |
1 files changed, 26 insertions, 33 deletions
diff --git a/test/openssl/test_pair.rb b/test/openssl/test_pair.rb index 29d5c9bbb1..08c15a0f75 100644 --- a/test/openssl/test_pair.rb +++ b/test/openssl/test_pair.rb @@ -10,7 +10,7 @@ module OpenSSL::SSLPairM ee_exts = [ ["keyUsage", "keyEncipherment,digitalSignature", true], ] - @svr_key = OpenSSL::TestUtils::Fixtures.pkey("rsa1024") + @svr_key = OpenSSL::TestUtils::Fixtures.pkey("rsa-1") @svr_cert = issue_cert(svr_dn, @svr_key, 1, ee_exts, nil, nil) end @@ -23,7 +23,7 @@ module OpenSSL::SSLPairM sctx = OpenSSL::SSL::SSLContext.new sctx.cert = @svr_cert sctx.key = @svr_key - sctx.tmp_dh_callback = proc { OpenSSL::TestUtils::Fixtures.pkey_dh("dh1024") } + sctx.tmp_dh_callback = proc { OpenSSL::TestUtils::Fixtures.pkey("dh-1") } sctx.options |= OpenSSL::SSL::OP_NO_COMPRESSION ssls = OpenSSL::SSL::SSLServer.new(tcps, sctx) ns = ssls.accept @@ -397,7 +397,7 @@ module OpenSSL::TestPairM ctx2 = OpenSSL::SSL::SSLContext.new ctx2.cert = @svr_cert ctx2.key = @svr_key - ctx2.tmp_dh_callback = proc { OpenSSL::TestUtils::Fixtures.pkey_dh("dh1024") } + ctx2.tmp_dh_callback = proc { OpenSSL::TestUtils::Fixtures.pkey("dh-1") } sock1, sock2 = tcp_pair @@ -442,54 +442,47 @@ module OpenSSL::TestPairM end def test_connect_accept_nonblock - ctx = OpenSSL::SSL::SSLContext.new() + ctx = OpenSSL::SSL::SSLContext.new ctx.cert = @svr_cert ctx.key = @svr_key - ctx.tmp_dh_callback = proc { OpenSSL::TestUtils::Fixtures.pkey_dh("dh1024") } + ctx.tmp_dh_callback = proc { OpenSSL::TestUtils::Fixtures.pkey("dh-1") } sock1, sock2 = tcp_pair th = Thread.new { s2 = OpenSSL::SSL::SSLSocket.new(sock2, ctx) - s2.sync_close = true - begin + 5.times { + begin + break s2.accept_nonblock + rescue IO::WaitReadable + IO.select([s2], nil, nil, 1) + rescue IO::WaitWritable + IO.select(nil, [s2], nil, 1) + end sleep 0.2 - s2.accept_nonblock + } + } + + s1 = OpenSSL::SSL::SSLSocket.new(sock1) + 5.times { + begin + break s1.connect_nonblock rescue IO::WaitReadable - IO.select([s2]) - retry + IO.select([s1], nil, nil, 1) rescue IO::WaitWritable - IO.select(nil, [s2]) - retry + IO.select(nil, [s1], nil, 1) end - s2 - } - - sleep 0.1 - ctx = OpenSSL::SSL::SSLContext.new() - s1 = OpenSSL::SSL::SSLSocket.new(sock1, ctx) - begin sleep 0.2 - s1.connect_nonblock - rescue IO::WaitReadable - IO.select([s1]) - retry - rescue IO::WaitWritable - IO.select(nil, [s1]) - retry - end - s1.sync_close = true + } s2 = th.value s1.print "a\ndef" assert_equal("a\n", s2.gets) ensure - th.join if th - s1.close if s1 && !s1.closed? - s2.close if s2 && !s2.closed? - sock1.close if sock1 && !sock1.closed? - sock2.close if sock2 && !sock2.closed? + sock1&.close + sock2&.close + th&.join end end |