Skip to content

Commit 9acc0ef

Browse files
committed
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' ```
1 parent 6fc8311 commit 9acc0ef

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

test/net/http/test_https_proxy.rb

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ def test_https_proxy_authentication
4444
}
4545
end
4646

47+
48+
def read_fixture(key)
49+
File.read(File.expand_path("../fixtures/#{key}", __dir__))
50+
end
51+
4752
def test_https_proxy_ssl_connection
4853
begin
4954
OpenSSL
@@ -53,14 +58,8 @@ def test_https_proxy_ssl_connection
5358

5459
tcpserver = TCPServer.new("127.0.0.1", 0)
5560
ctx = OpenSSL::SSL::SSLContext.new
56-
ctx.key = OpenSSL::PKey::RSA.new 2048
57-
ctx.cert = OpenSSL::X509::Certificate.new
58-
ctx.cert.subject = OpenSSL::X509::Name.new [['CN', 'localhost']]
59-
ctx.cert.issuer = ctx.cert.subject
60-
ctx.cert.public_key = ctx.key
61-
ctx.cert.not_before = Time.now
62-
ctx.cert.not_after = Time.now + 60 * 60 * 24
63-
ctx.cert.sign ctx.key, OpenSSL::Digest::SHA1.new
61+
ctx.key = OpenSSL::PKey.read(read_fixture("server.key"))
62+
ctx.cert = OpenSSL::X509::Certificate.new(read_fixture("server.crt"))
6463
serv = OpenSSL::SSL::SSLServer.new(tcpserver, ctx)
6564

6665
_, port, _, _ = serv.addr
@@ -92,4 +91,3 @@ def test_https_proxy_ssl_connection
9291
assert_join_threads([client_thread, server_thread])
9392
end
9493
end if defined?(OpenSSL)
95-

0 commit comments

Comments
 (0)