diff --git a/src/test/ruby/pkey-cert.pem b/src/test/ruby/pkey-cert.pem new file mode 100644 index 00000000..c6d913d3 --- /dev/null +++ b/src/test/ruby/pkey-cert.pem @@ -0,0 +1,32 @@ +-----BEGIN CERTIFICATE----- +MIIFcDCCA1igAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MREwDwYDVQQDDAhqb3Bl +bnNzbDEVMBMGCgmSJomT8ixkARkWBWpydWJ5MRMwEQYKCZImiZPyLGQBGRYDb3Jn +MB4XDTI0MDQwMzEzMjgyM1oXDTI1MDQwMzEzMjgyM1owPzERMA8GA1UEAwwIam9w +ZW5zc2wxFTATBgoJkiaJk/IsZAEZFgVqcnVieTETMBEGCgmSJomT8ixkARkWA29y +ZzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAJ4wLFlxtSIaRic+ag6y +rq75Ay/cSSQI4BrPx/Zb7hjHZ645lgyriT1vbkUkT0LJS9Cy6WZ7br0Z7hzfWc+k +FuBoizbWI5KjF5FRiPOuTucxPkNiti1e3LbGGQMlOJbrB4guWBxCUzOb2ZeTKj95 +Edna5+g5hxsDI6ECEn6IYf0gXq0xXRNaTa1u+lfelbT6LSHxYiTADJlWEKieR2ED +MUSwZNyM37ojwLQ1SlWZXIc6AbFviSV3cckDX2TRt70W53tIXFydc2zFqPF3w+gZ +DjPukkP7JnbcgMLy9EBlbhdR9jaL8R3TbVXktKSseBRrGGDeXpPH/LPUcOun2Jzp +nEVeMmQJ+Ec9TldQ/o8bCcZ6eV/sk56con7IUX6Gq/+pSSQqqjb3/2oC4kqdM6Dj +GcpmB44oLLdg6tcI8qUd9OAopQRkPOI9yyKjA6Gpwa918u8tGX7lryzyhc4OOeFv +QwoUknNPlMXU3tMyXRLhsAekyUqqglCfaY+ZqvNW5cJbxX5G64cCZuFhb7My21yz +zhZCn3tDHegCMtA+bAIfBX+Dg2Mt5J4rVJoy9ZDzWgs6ch6NW7pO2umuxFVXoHtg +VMNsFvd5gUY+Bvd662ARbZ1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zpJ+OtzEKFFgm +/ddfDIqVbsMpOV0vb03z3N5cKpqlXhLMJUIjscTMWk5DMsmhLK68yhTDTaXZzK/Y +bXMAaZvmPMWY39farAQNCHnnSQLhCmE= +-----END PRIVATE KEY----- diff --git a/src/test/ruby/test_pkey.rb b/src/test/ruby/test_pkey.rb index ad666094..5bcf50c3 100644 --- a/src/test/ruby/test_pkey.rb +++ b/src/test/ruby/test_pkey.rb @@ -14,6 +14,20 @@ def test_pkey_read assert_equal OpenSSL::PKey::RSA.new(KEY).e, pkey.e end + def test_pkey_read_pkcs8_and_check_with_cert + pkey = File.expand_path('pkey-pkcs8.pem', File.dirname(__FILE__)) + pkey = OpenSSL::PKey.read(File.read(pkey), nil) + + assert_true pkey.private? + assert_true pkey.public? + assert pkey.public_key.to_s + + cert = File.expand_path('pkey-cert.pem', File.dirname(__FILE__)) + cert = OpenSSL::X509::Certificate.new(File.read(cert)) + + assert_true cert.check_private_key(pkey) + end + def test_to_java pkey = OpenSSL::PKey.read(KEY) assert_kind_of java.security.PublicKey, pkey.to_java