cd5466
From 9596788bdd2d061bef042485af14262e9fc4020c Mon Sep 17 00:00:00 2001
cd5466
From: Kazuki Yamaguchi <k@rhe.jp>
cd5466
Date: Thu, 13 Aug 2020 23:20:55 +0900
cd5466
Subject: [PATCH] test/openssl/test_pkcs12: fix test failures with OpenSSL 3.0
cd5466
cd5466
OpenSSL's PKCS12_create() by default uses pbewithSHAAnd40BitRC2-CBC for
cd5466
encryption of the certificates. However, in OpenSSL 3.0, the algorithm
cd5466
is part of the legacy provider and is not enabled by default.
cd5466
cd5466
Specify another algorithm that is still in the default provider for
cd5466
these test cases.
cd5466
---
cd5466
 test/openssl/test_pkcs12.rb | 297 ++++++++++++++++++------------------
cd5466
 1 file changed, 149 insertions(+), 148 deletions(-)
cd5466
cd5466
diff --git a/test/openssl/test_pkcs12.rb b/test/openssl/test_pkcs12.rb
cd5466
index fdbe753b17..ec676743bc 100644
cd5466
--- a/test/openssl/test_pkcs12.rb
cd5466
+++ b/test/openssl/test_pkcs12.rb
cd5466
@@ -5,6 +5,9 @@
cd5466
 
cd5466
 module OpenSSL
cd5466
   class TestPKCS12 < OpenSSL::TestCase
cd5466
+    DEFAULT_PBE_PKEYS = "PBE-SHA1-3DES"
cd5466
+    DEFAULT_PBE_CERTS = "PBE-SHA1-3DES"
cd5466
+
cd5466
     def setup
cd5466
       super
cd5466
       ca = OpenSSL::X509::Name.parse("/DC=org/DC=ruby-lang/CN=CA")
cd5466
@@ -14,47 +17,41 @@ def setup
cd5466
         ["subjectKeyIdentifier","hash",false],
cd5466
         ["authorityKeyIdentifier","keyid:always",false],
cd5466
       ]
cd5466
-      @cacert = issue_cert(ca, Fixtures.pkey("rsa2048"), 1, ca_exts, nil, nil)
cd5466
+      ca_key = Fixtures.pkey("rsa-1")
cd5466
+      @cacert = issue_cert(ca, ca_key, 1, ca_exts, nil, nil)
cd5466
 
cd5466
       inter_ca = OpenSSL::X509::Name.parse("/DC=org/DC=ruby-lang/CN=Intermediate CA")
cd5466
-      inter_ca_key = OpenSSL::PKey.read <<-_EOS_
cd5466
------BEGIN RSA PRIVATE KEY-----
cd5466
-MIICXAIBAAKBgQDp7hIG0SFMG/VWv1dBUWziAPrNmkMXJgTCAoB7jffzRtyyN04K
cd5466
-oq/89HAszTMStZoMigQURfokzKsjpUp8OYCAEsBtt9d5zPndWMz/gHN73GrXk3LT
cd5466
-ZsxEn7Xv5Da+Y9F/Hx2QZUHarV5cdZixq2NbzWGwrToogOQMh2pxN3Z/0wIDAQAB
cd5466
-AoGBAJysUyx3olpsGzv3OMRJeahASbmsSKTXVLZvoIefxOINosBFpCIhZccAG6UV
cd5466
-5c/xCvS89xBw8aD15uUfziw3AuT8QPEtHCgfSjeT7aWzBfYswEgOW4XPuWr7EeI9
cd5466
-iNHGD6z+hCN/IQr7FiEBgTp6A+i/hffcSdR83fHWKyb4M7TRAkEA+y4BNd668HmC
cd5466
-G5MPRx25n6LixuBxrNp1umfjEI6UZgEFVpYOg4agNuimN6NqM253kcTR94QNTUs5
cd5466
-Kj3EhG1YWwJBAO5rUjiOyCNVX2WUQrOMYK/c1lU7fvrkdygXkvIGkhsPoNRzLPeA
cd5466
-HGJszKtrKD8bNihWpWNIyqKRHfKVD7yXT+kCQGCAhVCIGTRoypcDghwljHqLnysf
cd5466
-ci0h5ZdPcIqc7ODfxYhFsJ/Rql5ONgYsT5Ig/+lOQAkjf+TRYM4c2xKx2/8CQBvG
cd5466
-jv6dy70qDgIUgqzONtlmHeYyFzn9cdBO5sShdVYHvRHjFSMEXsosqK9zvW2UqvuK
cd5466
-FJx7d3f29gkzynCLJDkCQGQZlEZJC4vWmWJGRKJ24P6MyQn3VsPfErSKOg4lvyM3
cd5466
-Li8JsX5yIiuVYaBg/6ha3tOg4TCa5K/3r3tVliRZ2Es=
cd5466
------END RSA PRIVATE KEY-----
cd5466
-      _EOS_
cd5466
-      @inter_cacert = issue_cert(inter_ca, inter_ca_key, 2, ca_exts, @cacert, Fixtures.pkey("rsa2048"))
cd5466
+      inter_ca_key = Fixtures.pkey("rsa-2")
cd5466
+      @inter_cacert = issue_cert(inter_ca, inter_ca_key, 2, ca_exts, @cacert, ca_key)
cd5466
 
cd5466
       exts = [
cd5466
         ["keyUsage","digitalSignature",true],
cd5466
         ["subjectKeyIdentifier","hash",false],
cd5466
       ]
cd5466
       ee = OpenSSL::X509::Name.parse("/DC=org/DC=ruby-lang/CN=Ruby PKCS12 Test Certificate")
cd5466
-      @mykey = Fixtures.pkey("rsa1024")
cd5466
+      @mykey = Fixtures.pkey("rsa-3")
cd5466
       @mycert = issue_cert(ee, @mykey, 3, exts, @inter_cacert, inter_ca_key)
cd5466
     end
cd5466
 
cd5466
-    def test_create
cd5466
+    def test_create_single_key_single_cert
cd5466
       pkcs12 = OpenSSL::PKCS12.create(
cd5466
         "omg",
cd5466
         "hello",
cd5466
         @mykey,
cd5466
-        @mycert
cd5466
+        @mycert,
cd5466
+        nil,
cd5466
+        DEFAULT_PBE_PKEYS,
cd5466
+        DEFAULT_PBE_CERTS,
cd5466
       )
cd5466
-      assert_equal @mycert.to_der, pkcs12.certificate.to_der
cd5466
+      assert_equal @mycert, pkcs12.certificate
cd5466
       assert_equal @mykey.to_der, pkcs12.key.to_der
cd5466
       assert_nil pkcs12.ca_certs
cd5466
+
cd5466
+      der = pkcs12.to_der
cd5466
+      decoded = OpenSSL::PKCS12.new(der, "omg")
cd5466
+      assert_equal @mykey.to_der, decoded.key.to_der
cd5466
+      assert_equal @mycert, decoded.certificate
cd5466
+      assert_equal [], Array(decoded.ca_certs)
cd5466
     end
cd5466
 
cd5466
     def test_create_no_pass
cd5466
@@ -62,14 +59,17 @@ def test_create_no_pass
cd5466
         nil,
cd5466
         "hello",
cd5466
         @mykey,
cd5466
-        @mycert
cd5466
+        @mycert,
cd5466
+        nil,
cd5466
+        DEFAULT_PBE_PKEYS,
cd5466
+        DEFAULT_PBE_CERTS,
cd5466
       )
cd5466
-      assert_equal @mycert.to_der, pkcs12.certificate.to_der
cd5466
+      assert_equal @mycert, pkcs12.certificate
cd5466
       assert_equal @mykey.to_der, pkcs12.key.to_der
cd5466
       assert_nil pkcs12.ca_certs
cd5466
 
cd5466
       decoded = OpenSSL::PKCS12.new(pkcs12.to_der)
cd5466
-      assert_cert @mycert, decoded.certificate
cd5466
+      assert_equal @mycert, decoded.certificate
cd5466
     end
cd5466
 
cd5466
     def test_create_with_chain
cd5466
@@ -80,7 +80,9 @@ def test_create_with_chain
cd5466
         "hello",
cd5466
         @mykey,
cd5466
         @mycert,
cd5466
-        chain
cd5466
+        chain,
cd5466
+        DEFAULT_PBE_PKEYS,
cd5466
+        DEFAULT_PBE_CERTS,
cd5466
       )
cd5466
       assert_equal chain, pkcs12.ca_certs
cd5466
     end
cd5466
@@ -95,14 +97,16 @@ def test_create_with_chain_decode
cd5466
         "hello",
cd5466
         @mykey,
cd5466
         @mycert,
cd5466
-        chain
cd5466
+        chain,
cd5466
+        DEFAULT_PBE_PKEYS,
cd5466
+        DEFAULT_PBE_CERTS,
cd5466
       )
cd5466
 
cd5466
       decoded = OpenSSL::PKCS12.new(pkcs12.to_der, passwd)
cd5466
       assert_equal chain.size, decoded.ca_certs.size
cd5466
-      assert_include_cert @cacert, decoded.ca_certs
cd5466
-      assert_include_cert @inter_cacert, decoded.ca_certs
cd5466
-      assert_cert @mycert, decoded.certificate
cd5466
+      assert_include decoded.ca_certs, @cacert
cd5466
+      assert_include decoded.ca_certs, @inter_cacert
cd5466
+      assert_equal @mycert, decoded.certificate
cd5466
       assert_equal @mykey.to_der, decoded.key.to_der
cd5466
     end
cd5466
 
cd5466
@@ -126,8 +130,8 @@ def test_create_with_itr
cd5466
         @mykey,
cd5466
         @mycert,
cd5466
         [],
cd5466
-        nil,
cd5466
-        nil,
cd5466
+        DEFAULT_PBE_PKEYS,
cd5466
+        DEFAULT_PBE_CERTS,
cd5466
         2048
cd5466
       )
cd5466
 
cd5466
@@ -138,8 +142,8 @@ def test_create_with_itr
cd5466
           @mykey,
cd5466
           @mycert,
cd5466
           [],
cd5466
-          nil,
cd5466
-          nil,
cd5466
+          DEFAULT_PBE_PKEYS,
cd5466
+          DEFAULT_PBE_CERTS,
cd5466
           "omg"
cd5466
         )
cd5466
       end
cd5466
@@ -152,7 +156,8 @@ def test_create_with_mac_itr
cd5466
         @mykey,
cd5466
         @mycert,
cd5466
         [],
cd5466
-        nil,
cd5466
+        DEFAULT_PBE_PKEYS,
cd5466
+        DEFAULT_PBE_CERTS,
cd5466
         nil,
cd5466
         nil,
cd5466
         2048
cd5466
@@ -165,148 +170,144 @@ def test_create_with_mac_itr
cd5466
           @mykey,
cd5466
           @mycert,
cd5466
           [],
cd5466
-          nil,
cd5466
-          nil,
cd5466
+          DEFAULT_PBE_PKEYS,
cd5466
+          DEFAULT_PBE_CERTS,
cd5466
           nil,
cd5466
           "omg"
cd5466
         )
cd5466
       end
cd5466
     end
cd5466
 
cd5466
-    def test_new_with_one_key_and_one_cert
cd5466
-      # generated with:
cd5466
-      #   openssl version #=> OpenSSL 1.0.2h  3 May 2016
cd5466
-      #   openssl pkcs12 -in <@mycert> -inkey <RSA1024> -export -out <out>
cd5466
-      str = <<~EOF.unpack("m").first
cd5466
-MIIGQQIBAzCCBgcGCSqGSIb3DQEHAaCCBfgEggX0MIIF8DCCAu8GCSqGSIb3DQEH
cd5466
-BqCCAuAwggLcAgEAMIIC1QYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQIeZPM
cd5466
-Rh6KiXgCAggAgIICqL6O+LCZmBzdIg6mozPF3FpY0hVbWHvTNMiDHieW3CrAanhN
cd5466
-YCH2/wHqH8WpFpEWwF0qEEXAWjHsIlYB4Cfqo6b7XpuZe5eVESsjNTOTMF1JCUJj
cd5466
-A6iNefXmCFLync1JK5LUodRDhTlKLU1WPK20X9X4vuEwHn8wt5RUb8P0E+Xh6rpS
cd5466
-XC4LkZKT45zF3cJa/n5+dW65ohVGNVnF9D1bCNEKHMOllK1V9omutQ9slW88hpga
cd5466
-LGiFsJoFOb/ESGb78KO+bd6zbX1MdK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gDYh/kgJFGQAaWUOjLI+7dCEESonXn
cd5466
-F3Jh2uPbnDF9MGJyAFoNgWFhgSpi1cf6AUi87GY4Oyur88ddJ1o0D0Kz2uw8/bpG
cd5466
-s3O4PYnIW5naZ8mozzbnYByEFk7PoTwM7VhoFBfYNtBoAI8+hBnPY/Y71YUojEXf
cd5466
-SeX6QbtkIANfzS1XuFNKElShC3DPQIHpKzaatEsfxHfP+8VOav6zcn4mioao7NHA
cd5466
-x7Dp6R1enFGoQOq4UNjBT8YjnkG5vW8zQHW2dAHLTJBq6x2Fzm/4Pjo/8vM1FiGl
cd5466
-BQdW5vfDeJ/l6NgQm3xR9ka2E2HaDqIcj1zWbN8jy/bHPFJYuF/HH8MBV/ngMIXE
cd5466
-vFEW/ToYv8eif0+EpUtzBsCKD4a7qYYYh87RmEVoQU96q6m+UbhpD2WztYfAPkfo
cd5466
-OSL9j2QHhVczhL7OAgqNeM95pOsjA9YMe7exTeqK31LYnTX8oH8WJD1xGbRSJYgu
cd5466
-SY6PQbumcJkc/TFPn0GeVUpiDdf83SeG50lo/i7UKQi2l1hi5Y51fQhnBnyMr68D
cd5466
-llSZEvSWqfDxBJkBpeg6PIYvkTpEwKRJpVQoM3uYvdqVSSnW6rydqIb+snfOrlhd
cd5466
-f+xCtq9xr+kHeTSqLIDRRAnMfgFRhY3IBlj6MSUwIwYJKoZIhvcNAQkVMRYEFBdb
cd5466
-8XGWehZ6oPj56Pf/uId46M9AMDEwITAJBgUrDgMCGgUABBRvSCB04/f8f13pp2PF
cd5466
-vyl2WuMdEwQIMWFFphPkIUICAggA
cd5466
-      EOF
cd5466
-      p12 = OpenSSL::PKCS12.new(str, "abc123")
cd5466
-
cd5466
-      assert_equal @mykey.to_der, p12.key.to_der
cd5466
-      assert_equal @mycert.subject.to_der, p12.certificate.subject.to_der
cd5466
-      assert_equal [], Array(p12.ca_certs)
cd5466
-    end
cd5466
-
cd5466
     def test_new_with_no_keys
cd5466
       # generated with:
cd5466
-      #   openssl pkcs12 -in <@mycert> -nokeys -export -out <out>
cd5466
+      #   openssl pkcs12 -certpbe PBE-SHA1-3DES -in <@mycert> -nokeys -export
cd5466
       str = <<~EOF.unpack("m").first
cd5466
-MIIDHAIBAzCCAuIGCSqGSIb3DQEHAaCCAtMEggLPMIICyzCCAscGCSqGSIb3DQEH
cd5466
-BqCCArgwggK0AgEAMIICrQYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQIX4+W
cd5466
-irqwH40CAggAgIICgOaCyo+5+6IOVoGCCL80c50bkkzAwqdXxvkKExJSdcJz2uMU
cd5466
-0gRrKnZEjL5wrUsN8RwZu8DvgQTEhNEkKsUgM7AWainmN/EnwohIdHZAHpm6WD67
cd5466
-I9kLGp0/DHrqZrV9P2dLfhXLUSQE8PI0tqZPZ8UEABhizkViw4eISTkrOUN7pGbN
cd5466
-Qtx/oqgitXDuX2polbxYYDwt9vfHZhykHoKgew26SeJyZfeMs/WZ6olEI4cQUAFr
cd5466
-mvYGuC1AxEGTo9ERmU8Pm16j9Hr9PFk50WYe+rnk9oX3wJogQ7XUWS5kYf7XRycd
cd5466
-NDkNiwV/ts94bbuaGZp1YA6I48FXpIc8b5fX7t9tY0umGaWy0bARe1L7o0Y89EPe
cd5466
-lMg25rOM7j3uPtFG8whbSfdETSy57UxzzTcJ6UwexeaK6wb2jqEmj5AOoPLWeaX0
cd5466
-LyOAszR3v7OPAcjIDYZGdrbb3MZ2f2vo2pdQfu9698BrWhXuM7Odh73RLhJVreNI
cd5466
-aezNOAtPyBlvGiBQBGTzRIYHSLL5Y5aVj2vWLAa7hjm5qTL5C5mFdDIo6TkEMr6I
cd5466
-OsexNQofEGs19kr8nARXDlcbEimk2VsPj4efQC2CEXZNzURsKca82pa62MJ8WosB
cd5466
-DTFd8X06zZZ4nED50vLopZvyW4fyW60lELwOyThAdG8UchoAaz2baqP0K4de44yM
cd5466
-Y5/yPFDu4+GoimipJfbiYviRwbzkBxYW8+958ILh0RtagLbvIGxbpaym9PqGjO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cd5466
+J3xBZ0gppzQ5fjoYiKjJpxTflRxUuxshk3ih6VUoKtqj/W18tBQ3g5SOlkgT
cd5466
+yCW8r74yZlfYmNrPyDMUQYpLUPWj2n71GF0KyPfTU5yOatRgvheh262w5BG3
cd5466
+omFY7mb3tCv8/U2jdMIoukRKacpZiagofz3SxojOJq52cHnCri+gTHBMX0cO
cd5466
+j58ygfntHWRzst0pV7Ze2X3fdCAJ4DokH6bNJNthcgmolFJ/y3V1tJjgsdtQ
cd5466
+7Pjn/vE6xUV0HXE2x4yoVYNirbAMIvkN/X+atxrN0dA4AchN+zGp8TAxMCEw
cd5466
+CQYFKw4DAhoFAAQUQ+6XXkyhf6uYgtbibILN2IjKnOAECLiqoY45MPCrAgII
cd5466
+AA==
cd5466
       EOF
cd5466
       p12 = OpenSSL::PKCS12.new(str, "abc123")
cd5466
 
cd5466
       assert_equal nil, p12.key
cd5466
       assert_equal nil, p12.certificate
cd5466
       assert_equal 1, p12.ca_certs.size
cd5466
-      assert_equal @mycert.subject.to_der, p12.ca_certs[0].subject.to_der
cd5466
+      assert_equal @mycert.subject, p12.ca_certs[0].subject
cd5466
     end
cd5466
 
cd5466
     def test_new_with_no_certs
cd5466
       # generated with:
cd5466
-      #   openssl pkcs12 -inkey <RSA1024> -nocerts -export -out <out>
cd5466
+      #   openssl pkcs12 -inkey fixtures/openssl/pkey/rsa-1.pem -nocerts -export
cd5466
       str = <<~EOF.unpack("m").first
cd5466
-MIIDJwIBAzCCAu0GCSqGSIb3DQEHAaCCAt4EggLaMIIC1jCCAtIGCSqGSIb3DQEH
cd5466
-AaCCAsMEggK/MIICuzCCArcGCyqGSIb3DQEMCgECoIICpjCCAqIwHAYKKoZIhvcN
cd5466
-AQwBAzAOBAg6AaYnJs84SwICCAAEggKAQzZH+fWSpcQYD1J7PsGSune85A++fLCQ
cd5466
-V7tacp2iv95GJkxwYmfTP176pJdgs00mceB9UJ/u9EX5nD0djdjjQjwo6sgKjY0q
cd5466
-cpVhZw8CMxw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pN5Ctm3vK7UGSBmPeNqkXOYf3QTJ9gStJEd0F6+DzTN5C
cd5466
+KGt1IyuGwZqL2Yk51FDIIkr9ykEnBMaA39LS7GFHEDNGlW+fKC7AzA0zfoOr
cd5466
+fXZlHMBuqHtXqk3zrsHRqGGoocigg4ctrhD1UREYKj+eIj1TBiRdf7c6+COf
cd5466
+NIOmej8pX3FmZ4ui+dDA8r2ctgsWHrb4A6iiH+v1DRA61GtoaA/tNRggewXW
cd5466
+VXCZCGWyyTuyHGOqq5ozrv5MlzZLWD/KV/uDsAWmy20RAed1C4AzcXlpX25O
cd5466
+M4SNl47g5VRNJRtMqokc8j6TjZrzMDEwITAJBgUrDgMCGgUABBRrkIRuS5qg
cd5466
+BC8fv38mue8LZVcbHQQIUNrWKEnskCoCAggA
cd5466
       EOF
cd5466
       p12 = OpenSSL::PKCS12.new(str, "abc123")
cd5466
 
cd5466
-      assert_equal @mykey.to_der, p12.key.to_der
cd5466
+      assert_equal Fixtures.pkey("rsa-1").to_der, p12.key.to_der
cd5466
       assert_equal nil, p12.certificate
cd5466
       assert_equal [], Array(p12.ca_certs)
cd5466
     end
cd5466
 
cd5466
     def test_dup
cd5466
-      p12 = OpenSSL::PKCS12.create("pass", "name", @mykey, @mycert)
cd5466
+      p12 = OpenSSL::PKCS12.create(
cd5466
+        "pass",
cd5466
+        "name",
cd5466
+        @mykey,
cd5466
+        @mycert,
cd5466
+        nil,
cd5466
+        DEFAULT_PBE_PKEYS,
cd5466
+        DEFAULT_PBE_CERTS,
cd5466
+      )
cd5466
       assert_equal p12.to_der, p12.dup.to_der
cd5466
     end
cd5466
-
cd5466
-    private
cd5466
-    def assert_cert expected, actual
cd5466
-      [
cd5466
-        :subject,
cd5466
-        :issuer,
cd5466
-        :serial,
cd5466
-        :not_before,
cd5466
-        :not_after,
cd5466
-      ].each do |attribute|
cd5466
-        assert_equal expected.send(attribute), actual.send(attribute)
cd5466
-      end
cd5466
-      assert_equal expected.to_der, actual.to_der
cd5466
-    end
cd5466
-
cd5466
-    def assert_include_cert cert, ary
cd5466
-      der = cert.to_der
cd5466
-      ary.each do |candidate|
cd5466
-        if candidate.to_der == der
cd5466
-          return true
cd5466
-        end
cd5466
-      end
cd5466
-      false
cd5466
-    end
cd5466
   end
cd5466
 end
cd5466
 
cd5466
-- 
cd5466
2.32.0
cd5466