[前][次][番号順一覧][スレッド一覧]

ruby-changes:44863

From: rhe <ko1@a...>
Date: Wed, 30 Nov 2016 00:48:53 +0900 (JST)
Subject: [ruby-changes:44863] rhe:r56936 (trunk): webrick: don't use OpenSSL::TestUtils from webrick tests

rhe	2016-11-30 00:48:47 +0900 (Wed, 30 Nov 2016)

  New Revision: 56936

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56936

  Log:
    webrick: don't use OpenSSL::TestUtils from webrick tests
    
    Follow net/http and open-uri. Don't rely on the constants/methods from
    OpenSSL::TestUtils.

  Modified files:
    trunk/test/webrick/test_httpproxy.rb
Index: test/webrick/test_httpproxy.rb
===================================================================
--- test/webrick/test_httpproxy.rb	(revision 56935)
+++ test/webrick/test_httpproxy.rb	(revision 56936)
@@ -6,7 +6,6 @@ require "webrick/httpproxy" https://github.com/ruby/ruby/blob/trunk/test/webrick/test_httpproxy.rb#L6
 begin
   require "webrick/ssl"
   require "net/https"
-  require File.expand_path("../openssl/utils.rb", File.dirname(__FILE__))
 rescue LoadError
   # test_connect will be skipped
 end
@@ -124,12 +123,19 @@ class TestWEBrickHTTPProxy < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/webrick/test_httpproxy.rb#L123
     exts = [
       ["keyUsage", "keyEncipherment,digitalSignature", true],
     ]
-    cert = OpenSSL::TestUtils.issue_cert(
-      subject, key, 1, Time.now, Time.now + 3600, exts,
-      nil, nil, OpenSSL::Digest::SHA1.new
-    )
+    cert = OpenSSL::X509::Certificate.new
+    cert.version = 2
+    cert.serial = 1
+    cert.subject = subject
+    cert.issuer = subject
+    cert.public_key = key
+    cert.not_before = Time.now - 3600
+    cert.not_after = Time.now + 3600
+    ef = OpenSSL::X509::ExtensionFactory.new(cert, cert)
+    exts.each {|args| cert.add_extension(ef.create_extension(*args)) }
+    cert.sign(key, "sha1")
     return cert
-  end if defined?(OpenSSL::TestUtils)
+  end if defined?(OpenSSL::SSL)
 
   def test_connect
     # Testing CONNECT to proxy server
@@ -139,7 +145,7 @@ class TestWEBrickHTTPProxy < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/webrick/test_httpproxy.rb#L145
     #    2.   ---- establish SSL session --->
     #    3.   ------- GET or POST ---------->
     #
-    key = OpenSSL::TestUtils::TEST_KEY_RSA1024
+    key = TEST_KEY_RSA2048
     cert = make_certificate(key, "127.0.0.1")
     s_config = {
       :SSLEnable =>true,
@@ -178,7 +184,7 @@ class TestWEBrickHTTPProxy < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/webrick/test_httpproxy.rb#L184
         }
       }
     }
-  end if defined?(OpenSSL::TestUtils)
+  end if defined?(OpenSSL::SSL)
 
   def test_upstream_proxy
     # Testing GET or POST through the upstream proxy server
@@ -246,7 +252,7 @@ class TestWEBrickHTTPProxy < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/webrick/test_httpproxy.rb#L252
         assert_equal(3, proxy_handler_called, up_log.call + log.call)
         assert_equal(3, request_handler_called, up_log.call + log.call)
 
-        if defined?(OpenSSL::TestUtils)
+        if defined?(OpenSSL::SSL)
           # Testing CONNECT to the upstream proxy server
           #
           #  client -------> proxy -------> proxy -------> https
@@ -254,7 +260,7 @@ class TestWEBrickHTTPProxy < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/webrick/test_httpproxy.rb#L260
           #    2.   -------- establish SSL session ------>
           #    3.   ---------- GET or POST -------------->
           #
-          key = OpenSSL::TestUtils::TEST_KEY_RSA1024
+          key = TEST_KEY_RSA2048
           cert = make_certificate(key, "127.0.0.1")
           s_config = {
             :SSLEnable =>true,
@@ -287,4 +293,36 @@ class TestWEBrickHTTPProxy < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/webrick/test_httpproxy.rb#L293
       }
     }
   end
+
+  if defined?(OpenSSL::SSL)
+    TEST_KEY_RSA2048 = OpenSSL::PKey.read <<-_end_of_pem_
+-----BEGIN RSA PRIVATE KEY-----
+MIIEpAIBAAKCAQEAuV9ht9J7k4NBs38jOXvvTKY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sT0yYm5TFsUEr4sA3xcPfe4cV8sZb9k/QEGYb1+SWWZ+AHPV3UW5fl8kTbSNb
+v4ng8i8rVVQ0ANbJO9e5CUrepein2MPL0AkOATR8M7t7dGGpvYV0cFk8ZrFx0oId
+U0PgYDotF/iueBWlbsOM430CgYEAqYI95dFyPI5/AiSkY5queeb8+mQH62sdcCCr
+vd/w/CZA/K5sbAo4SoTj8dLk4evU6HtIa0DOP63y071eaxvRpTNqLUOgmLh+D6gS
+Cc7TfLuFrD+WDBatBd5jZ+SoHccVrLR/4L8jeodo5FPW05A+9gnKXEXsTxY4LOUC
+9bS4e1kCgYAqVXZh63JsMwoaxCYmQ66eJojKa47VNrOeIZDZvd2BPVf30glBOT41
+gBoDG3WMPZoQj9pb7uMcrnvs4APj2FIhMU8U15LcPAj59cD6S6rWnAxO8NFK7HQG
+4Jxg3JNNf8ErQoCHb1B3oVdXJkmbJkARoDpBKmTCgKtP8ADYLmVPQw==
+-----END RSA PRIVATE KEY-----
+    _end_of_pem_
+  end
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]