@@ -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
9493end if defined? ( OpenSSL )
95-
0 commit comments