pvalena / rpms / ruby

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