dd2565
From b0bcb19cb4f95d260c5993df0aaa3667522fb99d Mon Sep 17 00:00:00 2001
dd2565
From: Kazuki Yamaguchi <k@rhe.jp>
dd2565
Date: Thu, 16 Aug 2018 20:54:47 +0900
dd2565
Subject: [PATCH 1/2] test/openssl/test_pair: fix deadlock in
dd2565
 test_connect_accept_nonblock
dd2565
dd2565
Call IO.select with a timeout value and limit the number of retries to
dd2565
prevent stacking forever.
dd2565
dd2565
Reference: https://github.com/ruby/openssl/issues/214
dd2565
---
dd2565
 test/openssl/test_pair.rb | 51 ++++++++++++++++++++---------------------------
dd2565
 1 file changed, 22 insertions(+), 29 deletions(-)
dd2565
dd2565
diff --git a/test/openssl/test_pair.rb b/test/openssl/test_pair.rb
dd2565
index ea5f0dcf..eac3655e 100644
dd2565
--- a/test/openssl/test_pair.rb
dd2565
+++ b/test/openssl/test_pair.rb
dd2565
@@ -442,7 +442,7 @@ def test_connect_accept_nonblock_no_exception
dd2565
   end
dd2565
 
dd2565
   def test_connect_accept_nonblock
dd2565
-    ctx = OpenSSL::SSL::SSLContext.new()
dd2565
+    ctx = OpenSSL::SSL::SSLContext.new
dd2565
     ctx.cert = @svr_cert
dd2565
     ctx.key = @svr_key
dd2565
     ctx.tmp_dh_callback = proc { OpenSSL::TestUtils::Fixtures.pkey_dh("dh1024") }
dd2565
@@ -451,45 +451,38 @@ def test_connect_accept_nonblock
dd2565
 
dd2565
     th = Thread.new {
dd2565
       s2 = OpenSSL::SSL::SSLSocket.new(sock2, ctx)
dd2565
-      s2.sync_close = true
dd2565
-      begin
dd2565
+      5.times {
dd2565
+        begin
dd2565
+          break s2.accept_nonblock
dd2565
+        rescue IO::WaitReadable
dd2565
+          IO.select([s2], nil, nil, 1)
dd2565
+        rescue IO::WaitWritable
dd2565
+          IO.select(nil, [s2], nil, 1)
dd2565
+        end
dd2565
         sleep 0.2
dd2565
-        s2.accept_nonblock
dd2565
+      }
dd2565
+    }
dd2565
+
dd2565
+    s1 = OpenSSL::SSL::SSLSocket.new(sock1)
dd2565
+    5.times {
dd2565
+      begin
dd2565
+        break s1.connect_nonblock
dd2565
       rescue IO::WaitReadable
dd2565
-        IO.select([s2])
dd2565
-        retry
dd2565
+        IO.select([s1], nil, nil, 1)
dd2565
       rescue IO::WaitWritable
dd2565
-        IO.select(nil, [s2])
dd2565
-        retry
dd2565
+        IO.select(nil, [s1], nil, 1)
dd2565
       end
dd2565
-      s2
dd2565
-    }
dd2565
-
dd2565
-    sleep 0.1
dd2565
-    ctx = OpenSSL::SSL::SSLContext.new()
dd2565
-    s1 = OpenSSL::SSL::SSLSocket.new(sock1, ctx)
dd2565
-    begin
dd2565
       sleep 0.2
dd2565
-      s1.connect_nonblock
dd2565
-    rescue IO::WaitReadable
dd2565
-      IO.select([s1])
dd2565
-      retry
dd2565
-    rescue IO::WaitWritable
dd2565
-      IO.select(nil, [s1])
dd2565
-      retry
dd2565
-    end
dd2565
-    s1.sync_close = true
dd2565
+    }
dd2565
 
dd2565
     s2 = th.value
dd2565
 
dd2565
     s1.print "a\ndef"
dd2565
     assert_equal("a\n", s2.gets)
dd2565
   ensure
dd2565
-    th.join if th
dd2565
-    s1.close if s1 && !s1.closed?
dd2565
-    s2.close if s2 && !s2.closed?
dd2565
-    sock1.close if sock1 && !sock1.closed?
dd2565
-    sock2.close if sock2 && !sock2.closed?
dd2565
+    sock1&.close
dd2565
+    sock2&.close
dd2565
+    th&.join
dd2565
   end
dd2565
 end
dd2565
 
dd2565
dd2565
From 5ba99ad7ae1267ed964f53906530579299f3fcc6 Mon Sep 17 00:00:00 2001
dd2565
From: Kazuki Yamaguchi <k@rhe.jp>
dd2565
Date: Thu, 16 Aug 2018 20:04:13 +0900
dd2565
Subject: [PATCH 2/2] test: use larger keys for SSL tests
dd2565
dd2565
Some systems enforce a system-wide policy to restrict key sizes used in
dd2565
SSL/TLS. Use larger ones if possible so that the test suite runs
dd2565
successfully.
dd2565
dd2565
New PEM files test/openssl/fixtures/pkey/{dh-1,rsa-1,rsa-2,rsa-3}.pem are added
dd2565
to the tree, and SSL tests now use them instead of the fixed-size keys.
dd2565
dd2565
Reference: https://github.com/ruby/openssl/issues/215
dd2565
---
dd2565
 test/openssl/fixtures/pkey/dh-1.pem  | 13 +++++++++
dd2565
 test/openssl/fixtures/pkey/rsa-1.pem | 51 ++++++++++++++++++++++++++++++++++++
dd2565
 test/openssl/fixtures/pkey/rsa-2.pem | 51 ++++++++++++++++++++++++++++++++++++
dd2565
 test/openssl/fixtures/pkey/rsa-3.pem | 51 ++++++++++++++++++++++++++++++++++++
dd2565
 test/openssl/test_pair.rb            |  8 +++---
dd2565
 test/openssl/test_pkey_dh.rb         |  8 +++---
dd2565
 test/openssl/test_ssl.rb             | 11 ++++----
dd2565
 test/openssl/utils.rb                | 14 +++++-----
dd2565
 8 files changed, 186 insertions(+), 21 deletions(-)
dd2565
 create mode 100644 test/openssl/fixtures/pkey/dh-1.pem
dd2565
 create mode 100644 test/openssl/fixtures/pkey/rsa-1.pem
dd2565
 create mode 100644 test/openssl/fixtures/pkey/rsa-2.pem
dd2565
 create mode 100644 test/openssl/fixtures/pkey/rsa-3.pem
dd2565
dd2565
diff --git a/test/openssl/fixtures/pkey/dh-1.pem b/test/openssl/fixtures/pkey/dh-1.pem
dd2565
new file mode 100644
dd2565
index 00000000..3340a6a1
dd2565
--- /dev/null
dd2565
+++ b/test/openssl/fixtures/pkey/dh-1.pem
dd2565
@@ -0,0 +1,13 @@
dd2565
+-----BEGIN DH PARAMETERS-----
dd2565
+MIICCAKCAgEAvRzXYxY6L2DjeYmm1eowtMDu1it3j+VwFr6s6PRWzc1apMtztr9G
dd2565
+xZ2mYndUAJLgNLO3n2fUDCYVMB6ZkcekW8Siocof3xWiMA6wqZ6uw0dsE3q7ZX+6
dd2565
+TLjgSjaXeGvjutvuEwVrFeaUi83bMgfXN8ToxIQVprIF35sYFt6fpbFATKfW7qqi
dd2565
+P1pQkjmCskU4tztaWvlLh0qg85wuQGnpJaQT3gS30378i0IGbA0EBvJcSpTHYbLa
dd2565
+nsdI9bfN/ZVgeolVMNMU9/n8R8vRhNPcHuciFwaqS656q+HavCIyxw/LfjSwwFvR
dd2565
+TngCn0wytRErkzFIXnRKckh8/BpI4S+0+l1NkOwG4WJ55KJ/9OOdZW5o/QCp2bDi
dd2565
+E0JN1EP/gkSom/prq8JR/yEqtsy99uc5nUxPmzv0IgdcFHZEfiQU7iRggEbx7qfQ
dd2565
+Ve55XksmmJInmpCy1bSabAEgIKp8Ckt5KLYZ0RgTXUhcEpsxEo6cuAwoSJT5o4Rp
dd2565
+yG3xow2ozPcqZkvb+d2CHj1sc54w9BVFAjVANEKmRil/9WKz14bu3wxEhOPqC54n
dd2565
+QojjLcoXSoT66ZUOQnYxTSiLtzoKGPy8cAVPbkBrXz2u2sj5gcvr1JjoGjdHm9/3
dd2565
+qnqC8fsTz8UndKNIQC337o4K0833bQMzRGl1/qjbAPit2B7E3b6xTZMCAQI=
dd2565
+-----END DH PARAMETERS-----
dd2565
diff --git a/test/openssl/fixtures/pkey/rsa-1.pem b/test/openssl/fixtures/pkey/rsa-1.pem
dd2565
new file mode 100644
dd2565
index 00000000..bd5a624f
dd2565
--- /dev/null
dd2565
+++ b/test/openssl/fixtures/pkey/rsa-1.pem
dd2565
@@ -0,0 +1,51 @@
dd2565
+-----BEGIN RSA PRIVATE KEY-----
dd2565
+MIIJJwIBAAKCAgEArIEJUYZrXhMfUXXdl2gLcXrRB4ciWNEeXt5UVLG0nPhygZwJ
dd2565
+xis8tOrjXOJEpUXUsfgF35pQiJLD4T9/Vp3zLFtMOOQjOR3AxjIelbH9KPyGFEr9
dd2565
+TcPtsJ24zhcG7RbwOGXR4iIcDaTx+bCLSAd7BjG3XHQtyeepGGRZkGyGUvXjPorH
dd2565
+XP+dQjQnMd09wv0GMZSqQ06PedUUKQ4PJRfMCP+mwjFP+rB3NZuThF0CsNmpoixg
dd2565
+GdoQ591Yrf5rf2Bs848JrYdqJlKlBL6rTFf2glHiC+mE5YRny7RZtv/qIkyUNotV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ShSPkWTDuj0rvxisu+SNmClqRUXWPZnSwnzoK9a86443efF3fs3d
dd2565
+UxCXTuxFUdGfgvXo2XStOBMCtcGSYflM3fv27b4C13mUXhY0O2yTgn8m9LyZsknc
dd2565
+xGalENpbWmwqrjYl8KOF2+gFZV68FZ67Bm6otkJ4ta80VJw6joT9/eIe6IA34KIw
dd2565
+G+ktAoIBAFRuPxzvC4ZSaasyX21l25mQbC9pdWDKEkqxCmp3VOyy6R4xnlgBOhwS
dd2565
+VeAacV2vQyvRfv4dSLIVkkNSRDHEqCWVlNk75TDXFCytIAyE54xAHbLqIVlY7yim
dd2565
+qHVB07F/FC6PxdkPPziAAU2DA5XVedSHibslg6jbbD4jU6qiJ1+hNrAZEs+jQC+C
dd2565
+n4Ri20y+Qbp0URb2+icemnARlwgr+3HjzQGL3gK4NQjYNmDBjEWOXl9aWWB90FNL
dd2565
+KahGwfAhxcVW4W56opCzwR7nsujV4eDXGba83itidRuQfd5pyWOyc1E86TYGwD/b
dd2565
+79OkEElv6Ea8uXTDVS075GmWATRapQECggEAd9ZAbyT+KouTfi2e6yLOosxSZfns
dd2565
+eF06QAJi5n9GOtdfK5fqdmHJqJI7wbubCnd0oxPeL71lRjrOAMXufaQRdZtfXSMn
dd2565
+B1TljteNrh1en5xF451rCPR/Y6tNKBvIKnhy1waO27/vA+ovXrm17iR9rRuGZ29i
dd2565
+IurlKA6z/96UdrSdpqITTCyTjSOBYg34f49ueGjlpL4+8HJq2wor4Cb1Sbv8ErqA
dd2565
+bsQ/Jz+KIGUiuFCfNa6d6McPRXIrGgzpprXgfimkV3nj49QyrnuCF/Pc4psGgIaN
dd2565
+l3EiGXzRt/55K7DQVadtbcjo9zREac8QnDD6dS/gOfJ82L7frQfMpNWgQA==
dd2565
+-----END RSA PRIVATE KEY-----
dd2565
diff --git a/test/openssl/fixtures/pkey/rsa-2.pem b/test/openssl/fixtures/pkey/rsa-2.pem
dd2565
new file mode 100644
dd2565
index 00000000..e4fd4f43
dd2565
--- /dev/null
dd2565
+++ b/test/openssl/fixtures/pkey/rsa-2.pem
dd2565
@@ -0,0 +1,51 @@
dd2565
+-----BEGIN RSA PRIVATE KEY-----
dd2565
+MIIJKAIBAAKCAgEA1HUbx825tG7+/ulC5DpDogzXqM2/KmeCwGXZY4XjiWa+Zj7b
dd2565
+ECkZwQh7zxFUsPixGqQKJSyFwCogdaPzYTRNtqKKaw/IWS0um1PTn4C4/9atbIsf
dd2565
+HVKu/fWg4VrZL+ixFIZxa8Z6pvTB2omMcx+uEzbXPsO01i1pHf7MaWBxUDGFyC9P
dd2565
+lASJBfFZAf2Ar1H99OTS4SP+gxM9Kk5tcc22r8uFiqqbhJmQNSDApdHvT1zSZxAc
dd2565
+T1BFEZqfmR0B0UegPyJc/9hW0dYpB9JjR29UaZRSta3LUMpqltoOF5bzaKVgMuBm
dd2565
+Qy79xJ71LjGp8bKhgRaWXyPsDzAC0MQlOW6En0v8LK8fntivJEvw9PNOMcZ8oMTn
dd2565
+no0NeVt32HiQJW8LIVo7dOLVFtguSBMWUVe8mdKbuIIULD6JlSYke9Ob6andUhzO
dd2565
+U79m/aRWs2yjD6o5QAktjFBARdPgcpTdWfppc8xpJUkQgRmVhINoIMT9W6Wl898E
dd2565
+P4aPx6mRV/k05ellN3zRgd9tx5dyNuj3RBaNmR47cAVvGYRQgtH9bQYs6jtf0oer
dd2565
+A5yIYEKspNRlZZJKKrQdLflQFOEwjQJyZnTk7Mp0y21wOuEGgZBexew55/hUJDC2
dd2565
+mQ8CqjV4ki/Mm3z6Cw3jXIMNBJkH7oveBGSX0S9bF8A/73oOCU3W/LkORxECAwEA
dd2565
+AQKCAgBLK7RMmYmfQbaPUtEMF2FesNSNMV72DfHBSUgFYpYDQ4sSeiLgMOqf1fSY
dd2565
+azVf+F4RYwED7iDUwRMDDKNMPUlR2WjIQKlOhCH9a0dxJAZQ3xA1W3QC2AJ6cLIf
dd2565
+ihlWTip5bKgszekPsYH1ZL2A7jCVM84ssuoE7cRHjKOelTUCf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g/ip2uq2NLPnA5JWcD+v682fRSvIj1pU0DRi6VsXlzhs+1q3+sgqiXGz
dd2565
+u2ArFylh8TvC1gXUctXKZz/M3Rqr6aSNoejUGLmvHre+ja/k6Zwmu6ePtB7dL50d
dd2565
+6+xMTYquS4gLbrbSLcEu3iBAAnvRLreXK4KguPxaBdICB7v7epdpAKe3Z7hp/sst
dd2565
+eJj1+6KRdlcmt8fh5MPkBBXa6I/9XGmX5UEo7q4wAxeM9nuFWY3watz/EO9LiO6P
dd2565
+LmqUSWL65m4cX0VZPvhYEsHppKi1eoWGlHqS4Af5+aIXi2alu2iljQFeA+Q=
dd2565
+-----END RSA PRIVATE KEY-----
dd2565
diff --git a/test/openssl/fixtures/pkey/rsa-3.pem b/test/openssl/fixtures/pkey/rsa-3.pem
dd2565
new file mode 100644
dd2565
index 00000000..6c9c9ced
dd2565
--- /dev/null
dd2565
+++ b/test/openssl/fixtures/pkey/rsa-3.pem
dd2565
@@ -0,0 +1,51 @@
dd2565
+-----BEGIN RSA PRIVATE KEY-----
dd2565
+MIIJKAIBAAKCAgEAzn+YCcOh7BIRzrb7TEuhQLD545+/Fx/zCYO3l+y/8ogUxMTg
dd2565
+LG5HrcXlX3JP796ie90/GHIf8/lwczVhP1jk/keYjkwoTYDt477R7KRcJPyGqHRr
dd2565
+qLp7AnZxtz3JLNboTgO3bAYzlvtsSKU/R3oehBbGHzEWCP2UEYj/Kky0zpcjkhZU
dd2565
+jiErr9ARPq8+dOGqBf+CE2NLKYC1bu8hZe9AddvvN2SvfMN6uhJtEGZO1k8tScwf
dd2565
+AyvPJ1Po/6z08pzMAgfBUCE95waAVeYJWIOlnNB4eEievzlXdPB9vEt8OOwtWfQX
dd2565
+V8xyMsoKeAW05s413E0eTYx1aulFXdWwG2mWEBRtNzKF1iBudlg1a3x1zThWi1pY
dd2565
+jW5vROvoWZMCbl9bYQ/LxOCVqDoUl86+NPEGeuESMzm5NvOQA2e0Ty5wphnt9M19
dd2565
+Wcc8neBhb6iCG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HArdOMQJN1Pk
dd2565
+uCznVQKCAQAYY7DQbfa6eLQAMixomSb8lrvdxueGAgmyPyR93jGKS5Rqm2521ket
dd2565
+EBB07MZUxmyposDvbKhYSwv9TD9G5I/TKcMouP3BQM5m4vu3dygXQMhcfzk6Q5tO
dd2565
+k/SI8Gx3gjq8EhIhK/bJiLnKFJwkit3AEhPRtRSSnbgB0JDO1gUslHpwlg55MxRa
dd2565
+3V9CGN84/cTtq4tjLGwCB5F1Y+sRB/byBXHeqY2UDi1Rmnb6jtYYKGe2WpnQO84b
dd2565
+cuEUknskO75lFLpE6ykLU3koVaQ/+CVAjOtS1He2btWBiCJurNysU0P9pVHeqjJT
dd2565
+rDqpHPe1JK/F74783zyir5+/Tuph/9pdAoIBAANPdFRQkJVH8K6iuhxQk6vFqiYB
dd2565
+MUxpIVeLonD0p9TgMdezVNESht/AIutc0+5wabM45XuDWFRTuonvcE8lckv2Ux3a
dd2565
+AvSsamjuesxw2YmkEtzZouVqDU0+oxppQJiwBG3MiaHX9F5IfnK6YmQ6xPwZ6MXi
dd2565
+9feq1jR4KOc1ZrHtRMNgjnBWEFWroGe3FHgV7O133hpMSshRFmwcbE0nAaDr82U9
dd2565
+sl8dclDjEKBxaqjAeNajOr+BU0w0AAwWXL7dt/ctG2QClcj9wqbEfsXnOR10h4AI
dd2565
+rqkcvQrOLbTwcrOD/6R1rQfQXtEHKf1maThxosootAQZXdf6jxU3oonx3tU=
dd2565
+-----END RSA PRIVATE KEY-----
dd2565
diff --git a/test/openssl/test_pair.rb b/test/openssl/test_pair.rb
dd2565
index eac3655e..8d6ca1e9 100644
dd2565
--- a/test/openssl/test_pair.rb
dd2565
+++ b/test/openssl/test_pair.rb
dd2565
@@ -10,7 +10,7 @@ def setup
dd2565
     ee_exts = [
dd2565
       ["keyUsage", "keyEncipherment,digitalSignature", true],
dd2565
     ]
dd2565
-    @svr_key = OpenSSL::TestUtils::Fixtures.pkey("rsa1024")
dd2565
+    @svr_key = OpenSSL::TestUtils::Fixtures.pkey("rsa-1")
dd2565
     @svr_cert = issue_cert(svr_dn, @svr_key, 1, ee_exts, nil, nil)
dd2565
   end
dd2565
 
dd2565
@@ -23,7 +23,7 @@ def ssl_pair
dd2565
       sctx = OpenSSL::SSL::SSLContext.new
dd2565
       sctx.cert = @svr_cert
dd2565
       sctx.key = @svr_key
dd2565
-      sctx.tmp_dh_callback = proc { OpenSSL::TestUtils::Fixtures.pkey_dh("dh1024") }
dd2565
+      sctx.tmp_dh_callback = proc { OpenSSL::TestUtils::Fixtures.pkey("dh-1") }
dd2565
       sctx.options |= OpenSSL::SSL::OP_NO_COMPRESSION
dd2565
       ssls = OpenSSL::SSL::SSLServer.new(tcps, sctx)
dd2565
       ns = ssls.accept
dd2565
@@ -397,7 +397,7 @@ def test_connect_accept_nonblock_no_exception
dd2565
     ctx2 = OpenSSL::SSL::SSLContext.new
dd2565
     ctx2.cert = @svr_cert
dd2565
     ctx2.key = @svr_key
dd2565
-    ctx2.tmp_dh_callback = proc { OpenSSL::TestUtils::Fixtures.pkey_dh("dh1024") }
dd2565
+    ctx2.tmp_dh_callback = proc { OpenSSL::TestUtils::Fixtures.pkey("dh-1") }
dd2565
 
dd2565
     sock1, sock2 = tcp_pair
dd2565
 
dd2565
@@ -445,7 +445,7 @@ def test_connect_accept_nonblock
dd2565
     ctx = OpenSSL::SSL::SSLContext.new
dd2565
     ctx.cert = @svr_cert
dd2565
     ctx.key = @svr_key
dd2565
-    ctx.tmp_dh_callback = proc { OpenSSL::TestUtils::Fixtures.pkey_dh("dh1024") }
dd2565
+    ctx.tmp_dh_callback = proc { OpenSSL::TestUtils::Fixtures.pkey("dh-1") }
dd2565
 
dd2565
     sock1, sock2 = tcp_pair
dd2565
 
dd2565
diff --git a/test/openssl/test_pkey_dh.rb b/test/openssl/test_pkey_dh.rb
dd2565
index fb713813..79bf9bb7 100644
dd2565
--- a/test/openssl/test_pkey_dh.rb
dd2565
+++ b/test/openssl/test_pkey_dh.rb
dd2565
@@ -19,7 +19,7 @@ def test_new_break
dd2565
   end
dd2565
 
dd2565
   def test_DHparams
dd2565
-    dh1024 = Fixtures.pkey_dh("dh1024")
dd2565
+    dh1024 = Fixtures.pkey("dh1024")
dd2565
     asn1 = OpenSSL::ASN1::Sequence([
dd2565
       OpenSSL::ASN1::Integer(dh1024.p),
dd2565
       OpenSSL::ASN1::Integer(dh1024.g)
dd2565
@@ -42,7 +42,7 @@ def test_DHparams
dd2565
   end
dd2565
 
dd2565
   def test_public_key
dd2565
-    dh = Fixtures.pkey_dh("dh1024")
dd2565
+    dh = Fixtures.pkey("dh1024")
dd2565
     public_key = dh.public_key
dd2565
     assert_no_key(public_key) #implies public_key.public? is false!
dd2565
     assert_equal(dh.to_der, public_key.to_der)
dd2565
@@ -50,14 +50,14 @@ def test_public_key
dd2565
   end
dd2565
 
dd2565
   def test_generate_key
dd2565
-    dh = Fixtures.pkey_dh("dh1024").public_key # creates a copy
dd2565
+    dh = Fixtures.pkey("dh1024").public_key # creates a copy
dd2565
     assert_no_key(dh)
dd2565
     dh.generate_key!
dd2565
     assert_key(dh)
dd2565
   end
dd2565
 
dd2565
   def test_key_exchange
dd2565
-    dh = Fixtures.pkey_dh("dh1024")
dd2565
+    dh = Fixtures.pkey("dh1024")
dd2565
     dh2 = dh.public_key
dd2565
     dh.generate_key!
dd2565
     dh2.generate_key!
dd2565
diff --git a/test/openssl/test_ssl.rb b/test/openssl/test_ssl.rb
dd2565
index 408c7d82..2633f7c4 100644
dd2565
--- a/test/openssl/test_ssl.rb
dd2565
+++ b/test/openssl/test_ssl.rb
dd2565
@@ -708,7 +708,7 @@ def socketpair
dd2565
 
dd2565
   def test_tlsext_hostname
dd2565
     fooctx = OpenSSL::SSL::SSLContext.new
dd2565
-    fooctx.tmp_dh_callback = proc { Fixtures.pkey_dh("dh1024") }
dd2565
+    fooctx.tmp_dh_callback = proc { Fixtures.pkey("dh-1") }
dd2565
     fooctx.cert = @cli_cert
dd2565
     fooctx.key = @cli_key
dd2565
 
dd2565
@@ -760,7 +760,7 @@ def test_servername_cb_raises_an_exception_on_unknown_objects
dd2565
     ctx2 = OpenSSL::SSL::SSLContext.new
dd2565
     ctx2.cert = @svr_cert
dd2565
     ctx2.key = @svr_key
dd2565
-    ctx2.tmp_dh_callback = proc { Fixtures.pkey_dh("dh1024") }
dd2565
+    ctx2.tmp_dh_callback = proc { Fixtures.pkey("dh-1") }
dd2565
     ctx2.servername_cb = lambda { |args| Object.new }
dd2565
 
dd2565
     sock1, sock2 = socketpair
dd2565
@@ -1140,7 +1140,7 @@ def test_alpn_protocol_selection_cancel
dd2565
     ctx1 = OpenSSL::SSL::SSLContext.new
dd2565
     ctx1.cert = @svr_cert
dd2565
     ctx1.key = @svr_key
dd2565
-    ctx1.tmp_dh_callback = proc { Fixtures.pkey_dh("dh1024") }
dd2565
+    ctx1.tmp_dh_callback = proc { Fixtures.pkey("dh-1") }
dd2565
     ctx1.alpn_select_cb = -> (protocols) { nil }
dd2565
     ssl1 = OpenSSL::SSL::SSLSocket.new(sock1, ctx1)
dd2565
 
dd2565
@@ -1382,20 +1382,21 @@ def test_get_ephemeral_key
dd2565
   def test_dh_callback
dd2565
     pend "TLS 1.2 is not supported" unless tls12_supported?
dd2565
 
dd2565
+    dh = Fixtures.pkey("dh-1")
dd2565
     called = false
dd2565
     ctx_proc = -> ctx {
dd2565
       ctx.ssl_version = :TLSv1_2
dd2565
       ctx.ciphers = "DH:!NULL"
dd2565
       ctx.tmp_dh_callback = ->(*args) {
dd2565
         called = true
dd2565
-        Fixtures.pkey_dh("dh1024")
dd2565
+        dh
dd2565
       }
dd2565
     }
dd2565
     start_server(ctx_proc: ctx_proc) do |port|
dd2565
       server_connect(port) { |ssl|
dd2565
         assert called, "dh callback should be called"
dd2565
         if ssl.respond_to?(:tmp_key)
dd2565
-          assert_equal Fixtures.pkey_dh("dh1024").to_der, ssl.tmp_key.to_der
dd2565
+          assert_equal dh.to_der, ssl.tmp_key.to_der
dd2565
         end
dd2565
       }
dd2565
     end
dd2565
diff --git a/test/openssl/utils.rb b/test/openssl/utils.rb
dd2565
index b7ddd891..fe626ade 100644
dd2565
--- a/test/openssl/utils.rb
dd2565
+++ b/test/openssl/utils.rb
dd2565
@@ -42,10 +42,8 @@ module Fixtures
dd2565
 
dd2565
     def pkey(name)
dd2565
       OpenSSL::PKey.read(read_file("pkey", name))
dd2565
-    end
dd2565
-
dd2565
-    def pkey_dh(name)
dd2565
-      # DH parameters can be read by OpenSSL::PKey.read atm
dd2565
+    rescue OpenSSL::PKey::PKeyError
dd2565
+      # TODO: DH parameters can be read by OpenSSL::PKey.read atm
dd2565
       OpenSSL::PKey::DH.new(read_file("pkey", name))
dd2565
     end
dd2565
 
dd2565
@@ -157,9 +155,9 @@ class OpenSSL::SSLTestCase < OpenSSL::TestCase
dd2565
 
dd2565
   def setup
dd2565
     super
dd2565
-    @ca_key  = Fixtures.pkey("rsa2048")
dd2565
-    @svr_key = Fixtures.pkey("rsa1024")
dd2565
-    @cli_key = Fixtures.pkey("rsa2048")
dd2565
+    @ca_key  = Fixtures.pkey("rsa-1")
dd2565
+    @svr_key = Fixtures.pkey("rsa-2")
dd2565
+    @cli_key = Fixtures.pkey("rsa-3")
dd2565
     @ca  = OpenSSL::X509::Name.parse("/DC=org/DC=ruby-lang/CN=CA")
dd2565
     @svr = OpenSSL::X509::Name.parse("/DC=org/DC=ruby-lang/CN=localhost")
dd2565
     @cli = OpenSSL::X509::Name.parse("/DC=org/DC=ruby-lang/CN=localhost")
dd2565
@@ -200,7 +198,7 @@ def start_server(verify_mode: OpenSSL::SSL::VERIFY_NONE, start_immediately: true
dd2565
       ctx.cert_store = store
dd2565
       ctx.cert = @svr_cert
dd2565
       ctx.key = @svr_key
dd2565
-      ctx.tmp_dh_callback = proc { Fixtures.pkey_dh("dh1024") }
dd2565
+      ctx.tmp_dh_callback = proc { Fixtures.pkey("dh-1") }
dd2565
       ctx.verify_mode = verify_mode
dd2565
       ctx_proc.call(ctx) if ctx_proc
dd2565