2020-02-16 01:21:29 -05:00
|
|
|
# frozen_string_literal: true
|
2010-12-12 23:17:42 -05:00
|
|
|
require_relative "utils"
|
|
|
|
|
2017-09-03 08:35:27 -04:00
|
|
|
if defined?(OpenSSL)
|
2010-12-12 23:17:42 -05:00
|
|
|
|
|
|
|
module OpenSSL
|
2016-05-18 00:07:47 -04:00
|
|
|
class TestPKCS12 < OpenSSL::TestCase
|
2020-08-13 10:20:55 -04:00
|
|
|
DEFAULT_PBE_PKEYS = "PBE-SHA1-3DES"
|
|
|
|
DEFAULT_PBE_CERTS = "PBE-SHA1-3DES"
|
|
|
|
|
2010-12-12 23:17:42 -05:00
|
|
|
def setup
|
2016-12-10 03:12:02 -05:00
|
|
|
super
|
2011-07-26 20:31:43 -04:00
|
|
|
ca = OpenSSL::X509::Name.parse("/DC=org/DC=ruby-lang/CN=CA")
|
|
|
|
ca_exts = [
|
|
|
|
["basicConstraints","CA:TRUE",true],
|
|
|
|
["keyUsage","keyCertSign, cRLSign",true],
|
|
|
|
["subjectKeyIdentifier","hash",false],
|
|
|
|
["authorityKeyIdentifier","keyid:always",false],
|
|
|
|
]
|
2020-08-13 10:20:55 -04:00
|
|
|
ca_key = Fixtures.pkey("rsa-1")
|
|
|
|
@cacert = issue_cert(ca, ca_key, 1, ca_exts, nil, nil)
|
2011-07-26 20:31:43 -04:00
|
|
|
|
|
|
|
inter_ca = OpenSSL::X509::Name.parse("/DC=org/DC=ruby-lang/CN=Intermediate CA")
|
2020-08-13 10:20:55 -04:00
|
|
|
inter_ca_key = Fixtures.pkey("rsa-2")
|
|
|
|
@inter_cacert = issue_cert(inter_ca, inter_ca_key, 2, ca_exts, @cacert, ca_key)
|
2011-07-26 20:31:43 -04:00
|
|
|
|
|
|
|
exts = [
|
|
|
|
["keyUsage","digitalSignature",true],
|
|
|
|
["subjectKeyIdentifier","hash",false],
|
|
|
|
]
|
|
|
|
ee = OpenSSL::X509::Name.parse("/DC=org/DC=ruby-lang/CN=Ruby PKCS12 Test Certificate")
|
2020-08-13 10:20:55 -04:00
|
|
|
@mykey = Fixtures.pkey("rsa-3")
|
2017-09-03 08:35:27 -04:00
|
|
|
@mycert = issue_cert(ee, @mykey, 3, exts, @inter_cacert, inter_ca_key)
|
2010-12-12 23:17:42 -05:00
|
|
|
end
|
|
|
|
|
2020-08-13 10:20:55 -04:00
|
|
|
def test_create_single_key_single_cert
|
2010-12-12 23:17:42 -05:00
|
|
|
pkcs12 = OpenSSL::PKCS12.create(
|
|
|
|
"omg",
|
|
|
|
"hello",
|
2017-09-03 08:35:27 -04:00
|
|
|
@mykey,
|
2020-08-13 10:20:55 -04:00
|
|
|
@mycert,
|
|
|
|
nil,
|
|
|
|
DEFAULT_PBE_PKEYS,
|
|
|
|
DEFAULT_PBE_CERTS,
|
2010-12-12 23:17:42 -05:00
|
|
|
)
|
2020-08-13 10:20:55 -04:00
|
|
|
assert_equal @mycert, pkcs12.certificate
|
2017-09-03 08:35:27 -04:00
|
|
|
assert_equal @mykey.to_der, pkcs12.key.to_der
|
2010-12-12 23:17:42 -05:00
|
|
|
assert_nil pkcs12.ca_certs
|
2020-08-13 10:20:55 -04:00
|
|
|
|
|
|
|
der = pkcs12.to_der
|
|
|
|
decoded = OpenSSL::PKCS12.new(der, "omg")
|
|
|
|
assert_equal @mykey.to_der, decoded.key.to_der
|
|
|
|
assert_equal @mycert, decoded.certificate
|
|
|
|
assert_equal [], Array(decoded.ca_certs)
|
2010-12-12 23:17:42 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_create_no_pass
|
|
|
|
pkcs12 = OpenSSL::PKCS12.create(
|
|
|
|
nil,
|
|
|
|
"hello",
|
2017-09-03 08:35:27 -04:00
|
|
|
@mykey,
|
2020-08-13 10:20:55 -04:00
|
|
|
@mycert,
|
|
|
|
nil,
|
|
|
|
DEFAULT_PBE_PKEYS,
|
|
|
|
DEFAULT_PBE_CERTS,
|
2010-12-12 23:17:42 -05:00
|
|
|
)
|
2020-08-13 10:20:55 -04:00
|
|
|
assert_equal @mycert, pkcs12.certificate
|
2017-09-03 08:35:27 -04:00
|
|
|
assert_equal @mykey.to_der, pkcs12.key.to_der
|
2010-12-12 23:17:42 -05:00
|
|
|
assert_nil pkcs12.ca_certs
|
|
|
|
|
|
|
|
decoded = OpenSSL::PKCS12.new(pkcs12.to_der)
|
2020-08-13 10:20:55 -04:00
|
|
|
assert_equal @mycert, decoded.certificate
|
2010-12-12 23:17:42 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_create_with_chain
|
2011-07-26 20:31:43 -04:00
|
|
|
chain = [@inter_cacert, @cacert]
|
2010-12-12 23:17:42 -05:00
|
|
|
|
|
|
|
pkcs12 = OpenSSL::PKCS12.create(
|
|
|
|
"omg",
|
|
|
|
"hello",
|
2017-09-03 08:35:27 -04:00
|
|
|
@mykey,
|
2010-12-12 23:17:42 -05:00
|
|
|
@mycert,
|
2020-08-13 10:20:55 -04:00
|
|
|
chain,
|
|
|
|
DEFAULT_PBE_PKEYS,
|
|
|
|
DEFAULT_PBE_CERTS,
|
2010-12-12 23:17:42 -05:00
|
|
|
)
|
|
|
|
assert_equal chain, pkcs12.ca_certs
|
|
|
|
end
|
|
|
|
|
2011-07-26 20:31:43 -04:00
|
|
|
def test_create_with_chain_decode
|
|
|
|
chain = [@cacert, @inter_cacert]
|
|
|
|
|
|
|
|
passwd = "omg"
|
|
|
|
|
|
|
|
pkcs12 = OpenSSL::PKCS12.create(
|
|
|
|
passwd,
|
|
|
|
"hello",
|
2017-09-03 08:35:27 -04:00
|
|
|
@mykey,
|
2011-07-26 20:31:43 -04:00
|
|
|
@mycert,
|
2020-08-13 10:20:55 -04:00
|
|
|
chain,
|
|
|
|
DEFAULT_PBE_PKEYS,
|
|
|
|
DEFAULT_PBE_CERTS,
|
2011-07-26 20:31:43 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
decoded = OpenSSL::PKCS12.new(pkcs12.to_der, passwd)
|
|
|
|
assert_equal chain.size, decoded.ca_certs.size
|
2020-08-13 10:20:55 -04:00
|
|
|
assert_include decoded.ca_certs, @cacert
|
|
|
|
assert_include decoded.ca_certs, @inter_cacert
|
|
|
|
assert_equal @mycert, decoded.certificate
|
2017-09-03 08:35:27 -04:00
|
|
|
assert_equal @mykey.to_der, decoded.key.to_der
|
2011-07-26 20:31:43 -04:00
|
|
|
end
|
|
|
|
|
2010-12-12 23:17:42 -05:00
|
|
|
def test_create_with_bad_nid
|
2015-06-01 22:18:44 -04:00
|
|
|
assert_raise(ArgumentError) do
|
2010-12-12 23:17:42 -05:00
|
|
|
OpenSSL::PKCS12.create(
|
|
|
|
"omg",
|
|
|
|
"hello",
|
2017-09-03 08:35:27 -04:00
|
|
|
@mykey,
|
2010-12-12 23:17:42 -05:00
|
|
|
@mycert,
|
|
|
|
[],
|
|
|
|
"foo"
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_create_with_itr
|
|
|
|
OpenSSL::PKCS12.create(
|
|
|
|
"omg",
|
|
|
|
"hello",
|
2017-09-03 08:35:27 -04:00
|
|
|
@mykey,
|
2010-12-12 23:17:42 -05:00
|
|
|
@mycert,
|
|
|
|
[],
|
2020-08-13 10:20:55 -04:00
|
|
|
DEFAULT_PBE_PKEYS,
|
|
|
|
DEFAULT_PBE_CERTS,
|
2010-12-12 23:17:42 -05:00
|
|
|
2048
|
|
|
|
)
|
|
|
|
|
2015-06-01 22:18:44 -04:00
|
|
|
assert_raise(TypeError) do
|
2010-12-12 23:17:42 -05:00
|
|
|
OpenSSL::PKCS12.create(
|
|
|
|
"omg",
|
|
|
|
"hello",
|
2017-09-03 08:35:27 -04:00
|
|
|
@mykey,
|
2010-12-12 23:17:42 -05:00
|
|
|
@mycert,
|
|
|
|
[],
|
2020-08-13 10:20:55 -04:00
|
|
|
DEFAULT_PBE_PKEYS,
|
|
|
|
DEFAULT_PBE_CERTS,
|
2010-12-12 23:17:42 -05:00
|
|
|
"omg"
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_create_with_mac_itr
|
|
|
|
OpenSSL::PKCS12.create(
|
|
|
|
"omg",
|
|
|
|
"hello",
|
2017-09-03 08:35:27 -04:00
|
|
|
@mykey,
|
2010-12-12 23:17:42 -05:00
|
|
|
@mycert,
|
|
|
|
[],
|
2020-08-13 10:20:55 -04:00
|
|
|
DEFAULT_PBE_PKEYS,
|
|
|
|
DEFAULT_PBE_CERTS,
|
2010-12-12 23:17:42 -05:00
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
2048
|
|
|
|
)
|
|
|
|
|
2015-06-01 22:18:44 -04:00
|
|
|
assert_raise(TypeError) do
|
2010-12-12 23:17:42 -05:00
|
|
|
OpenSSL::PKCS12.create(
|
|
|
|
"omg",
|
|
|
|
"hello",
|
2017-09-03 08:35:27 -04:00
|
|
|
@mykey,
|
2010-12-12 23:17:42 -05:00
|
|
|
@mycert,
|
|
|
|
[],
|
2020-08-13 10:20:55 -04:00
|
|
|
DEFAULT_PBE_PKEYS,
|
|
|
|
DEFAULT_PBE_CERTS,
|
2010-12-12 23:17:42 -05:00
|
|
|
nil,
|
|
|
|
"omg"
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-09-07 21:09:19 -04:00
|
|
|
def test_new_with_no_keys
|
|
|
|
# generated with:
|
2020-08-13 10:20:55 -04:00
|
|
|
# openssl pkcs12 -certpbe PBE-SHA1-3DES -in <@mycert> -nokeys -export
|
2016-09-07 21:09:19 -04:00
|
|
|
str = <<~EOF.unpack("m").first
|
2020-08-13 10:20:55 -04:00
|
|
|
MIIGJAIBAzCCBeoGCSqGSIb3DQEHAaCCBdsEggXXMIIF0zCCBc8GCSqGSIb3
|
|
|
|
DQEHBqCCBcAwggW8AgEAMIIFtQYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQMw
|
|
|
|
DgQIjv5c3OHvnBgCAggAgIIFiMJa8Z/w7errRvCQPXh9dGQz3eJaFq3S2gXD
|
|
|
|
rh6oiwsg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Q+6XXkyhf6uYgtbibILN2IjKnOAECLiqoY45MPCrAgII
|
|
|
|
AA==
|
2016-09-07 21:09:19 -04:00
|
|
|
EOF
|
|
|
|
p12 = OpenSSL::PKCS12.new(str, "abc123")
|
|
|
|
|
|
|
|
assert_equal nil, p12.key
|
|
|
|
assert_equal nil, p12.certificate
|
|
|
|
assert_equal 1, p12.ca_certs.size
|
2020-08-13 10:20:55 -04:00
|
|
|
assert_equal @mycert.subject, p12.ca_certs[0].subject
|
2016-09-07 21:09:19 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_new_with_no_certs
|
|
|
|
# generated with:
|
2020-08-13 10:20:55 -04:00
|
|
|
# openssl pkcs12 -inkey fixtures/openssl/pkey/rsa-1.pem -nocerts -export
|
2016-09-07 21:09:19 -04:00
|
|
|
str = <<~EOF.unpack("m").first
|
2020-08-13 10:20:55 -04:00
|
|
|
MIIJ7wIBAzCCCbUGCSqGSIb3DQEHAaCCCaYEggmiMIIJnjCCCZoGCSqGSIb3
|
|
|
|
DQEHAaCCCYsEggmHMIIJgzCCCX8GCyqGSIb3DQEMCgECoIIJbjCCCWowHAYK
|
|
|
|
KoZIhvcNAQwBAzAOBAjX5nN8jyRKwQICCAAEgglIBIRLHfiY1mNHpl3FdX6+
|
|
|
|
72L+ZOVXnlZ1MY9HSeg0RMkCJcm0mJ2UD7INUOGXvwpK9fr6WJUZM1IqTihQ
|
|
|
|
1dM0crRC2m23aP7KtAlXh2DYD3otseDtwoN/NE19RsiJzeIiy5TSW1d47weU
|
|
|
|
+D4Ig/9FYVFPTDgMzdCxXujhvO/MTbZIjqtcS+IOyF+91KkXrHkfkGjZC7KS
|
|
|
|
WRmYw9BBuIPQEewdTI35sAJcxT8rK7JIiL/9mewbSE+Z28Wq1WXwmjL3oZm9
|
|
|
|
lw6+f515b197GYEGomr6LQqJJamSYpwQbTGHonku6Tf3ylB4NLFqOnRCKE4K
|
|
|
|
zRSSYIqJBlKHmQ4pDm5awoupHYxMZLZKZvXN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
|
|
M4SNl47g5VRNJRtMqokc8j6TjZrzMDEwITAJBgUrDgMCGgUABBRrkIRuS5qg
|
|
|
|
BC8fv38mue8LZVcbHQQIUNrWKEnskCoCAggA
|
2016-09-07 21:09:19 -04:00
|
|
|
EOF
|
|
|
|
p12 = OpenSSL::PKCS12.new(str, "abc123")
|
|
|
|
|
2020-08-13 10:20:55 -04:00
|
|
|
assert_equal Fixtures.pkey("rsa-1").to_der, p12.key.to_der
|
2016-09-07 21:09:19 -04:00
|
|
|
assert_equal nil, p12.certificate
|
|
|
|
assert_equal [], Array(p12.ca_certs)
|
|
|
|
end
|
|
|
|
|
2016-08-29 01:47:09 -04:00
|
|
|
def test_dup
|
2020-08-13 10:20:55 -04:00
|
|
|
p12 = OpenSSL::PKCS12.create(
|
|
|
|
"pass",
|
|
|
|
"name",
|
|
|
|
@mykey,
|
|
|
|
@mycert,
|
|
|
|
nil,
|
|
|
|
DEFAULT_PBE_PKEYS,
|
|
|
|
DEFAULT_PBE_CERTS,
|
|
|
|
)
|
2016-08-29 01:47:09 -04:00
|
|
|
assert_equal p12.to_der, p12.dup.to_der
|
|
|
|
end
|
2010-12-12 23:17:42 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|