diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2021-11-03 23:31:29 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2021-12-12 18:15:17 +0900 |
commit | 8c185e0ae5e42bf5f3d76a1a0898946671116fa3 (patch) | |
tree | 8632af0b12b4caedc6888d7f81fffb3e92825c9b | |
parent | 8193b7322ece2548eaf3d8acd1aec32bfc2cfdb9 (diff) | |
download | ruby-openssl-8c185e0ae5e42bf5f3d76a1a0898946671116fa3.tar.gz |
pkey: test parsing concatenated PEM string
PEM-encoded private keys are sometimes stored together with irrelevant
PEM blocks, such as the corresponding X.509 certificate.
PEM_read_bio_*() family automatically skips unknown PEM blocks, but on
OpenSSL 3.0 we will be using the new OSSL_DECODER API instead due to
some breaking changes around the password callback.
Let's add a test case so that we won't break the current behavior.
-rw-r--r-- | test/openssl/test_pkey_rsa.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/test/openssl/test_pkey_rsa.rb b/test/openssl/test_pkey_rsa.rb index dbe87ba4..7510658d 100644 --- a/test/openssl/test_pkey_rsa.rb +++ b/test/openssl/test_pkey_rsa.rb @@ -306,6 +306,12 @@ class OpenSSL::TestPKeyRSA < OpenSSL::PKeyTestCase assert_equal asn1.to_der, rsa1024.to_der assert_equal pem, rsa1024.export + + # Unknown PEM prepended + cert = issue_cert(OpenSSL::X509::Name.new([["CN", "nobody"]]), rsa1024, 1, [], nil, nil) + str = cert.to_text + cert.to_pem + rsa1024.to_pem + key = OpenSSL::PKey::RSA.new(str) + assert_same_rsa rsa1024, key end def test_RSAPrivateKey_encrypted |