summaryrefslogtreecommitdiff
path: root/test/net
diff options
context:
space:
mode:
authorHiroshi SHIBATA <[email protected]>2024-07-12 09:15:12 +0900
committerHiroshi SHIBATA <[email protected]>2024-07-12 09:15:12 +0900
commit9acc0efdc158111f2e5737ba9f51caaf491abf51 (patch)
treee2c10318b270a5b52b57e00a037ba3f1a5a07ab8 /test/net
parent6fc83118bbb03c049e470cf27dbf1e87654e6942 (diff)
Use fixture certificates to fix test failure with RHEL9.
http://rubyci.s3.amazonaws.com/rhel9/ruby-master/log/20240711T213004Z.fail.html.gz ``` 1) Error: HTTPSProxyTest#test_https_proxy_ssl_connection: OpenSSL::X509::CertificateError: invalid digest /home/chkbuild/chkbuild/tmp/build/20240711T213004Z/ruby/test/net/http/test_https_proxy.rb:63:in 'OpenSSL::X509::Certificate#sign' /home/chkbuild/chkbuild/tmp/build/20240711T213004Z/ruby/test/net/http/test_https_proxy.rb:63:in 'HTTPSProxyTest#test_https_proxy_ssl_connection' ```
Diffstat (limited to 'test/net')
-rw-r--r--test/net/http/test_https_proxy.rb16
1 files changed, 7 insertions, 9 deletions
diff --git a/test/net/http/test_https_proxy.rb b/test/net/http/test_https_proxy.rb
index d7da0cef13..4225f9836c 100644
--- a/test/net/http/test_https_proxy.rb
+++ b/test/net/http/test_https_proxy.rb
@@ -44,6 +44,11 @@ class HTTPSProxyTest < Test::Unit::TestCase
}
end
+
+ def read_fixture(key)
+ File.read(File.expand_path("../fixtures/#{key}", __dir__))
+ end
+
def test_https_proxy_ssl_connection
begin
OpenSSL
@@ -53,14 +58,8 @@ class HTTPSProxyTest < Test::Unit::TestCase
tcpserver = TCPServer.new("127.0.0.1", 0)
ctx = OpenSSL::SSL::SSLContext.new
- ctx.key = OpenSSL::PKey::RSA.new 2048
- ctx.cert = OpenSSL::X509::Certificate.new
- ctx.cert.subject = OpenSSL::X509::Name.new [['CN', 'localhost']]
- ctx.cert.issuer = ctx.cert.subject
- ctx.cert.public_key = ctx.key
- ctx.cert.not_before = Time.now
- ctx.cert.not_after = Time.now + 60 * 60 * 24
- ctx.cert.sign ctx.key, OpenSSL::Digest::SHA1.new
+ ctx.key = OpenSSL::PKey.read(read_fixture("server.key"))
+ ctx.cert = OpenSSL::X509::Certificate.new(read_fixture("server.crt"))
serv = OpenSSL::SSL::SSLServer.new(tcpserver, ctx)
_, port, _, _ = serv.addr
@@ -92,4 +91,3 @@ class HTTPSProxyTest < Test::Unit::TestCase
assert_join_threads([client_thread, server_thread])
end
end if defined?(OpenSSL)
-