diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2017-07-21 15:35:46 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2017-07-22 21:58:56 +0900 |
commit | 96211a3e4ed8242832b74f166d6435144438bd43 (patch) | |
tree | 702ea51e49c0dc9dc753e0a7cadffd631f9d60af /test | |
parent | 2a5ae3c7a53978145122a163e63a490a6a6c9993 (diff) | |
download | ruby-openssl-96211a3e4ed8242832b74f166d6435144438bd43.tar.gz |
ossl_pem_passwd_cb: handle nil from the block explicitlyky/pem-passwd-cb-get-rid-of-minlen
There is code that returns nil in the passphrase block on purpose (to
prevent OpenSSL from prompting on stdin):
OpenSSL::PKey.read(File.read("file.pem")) { nil }
This is working just by chance because the TypeError from StringValue()
is silently ignored. Let's short circuit in that case and save raising
a needless exception, as this pattern has become too common.
Diffstat (limited to 'test')
-rw-r--r-- | test/test_pkey_rsa.rb | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/test/test_pkey_rsa.rb b/test/test_pkey_rsa.rb index 381e7603..93760f74 100644 --- a/test/test_pkey_rsa.rb +++ b/test/test_pkey_rsa.rb @@ -248,6 +248,9 @@ class OpenSSL::TestPKeyRSA < OpenSSL::PKeyTestCase assert_match (/ENCRYPTED/), pem3c assert_equal key.to_der, OpenSSL::PKey.read(pem3c, "key").to_der assert_equal key.to_der, OpenSSL::PKey.read(pem3c) { "key" }.to_der + assert_raise(OpenSSL::PKey::PKeyError) { + OpenSSL::PKey.read(pem3c) { nil } + } end def test_dup |