diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2016-07-03 11:27:45 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-07-09 02:45:42 +0900 |
commit | 6c09fd3ef5422d798f6674094b9f222c3abae660 (patch) | |
tree | cdc087a5a4394f73295c9ea4671290f0b2ecb2b0 /test/test_pkey_rsa.rb | |
parent | 1b8bcdb1dc06626a285859570a1e67037df47d8e (diff) | |
download | ruby-openssl-6c09fd3ef5422d798f6674094b9f222c3abae660.tar.gz |
pkey: make PKey.read raise PKey::PKeyError rather than ArgumentErrortopic/pkey-read-pkey-error
PKey.read is a generic method to load an arbitrary PKey structure from a
PEM or DER encoded String. Each PKey classes's constructor also can load
from a String, but the behavior on error is different. While they raises
its own exception (are subclasses of PKey::PKeyError), PKey.read raises
ArgumentError. [Bug #11774]
Diffstat (limited to 'test/test_pkey_rsa.rb')
-rw-r--r-- | test/test_pkey_rsa.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/test/test_pkey_rsa.rb b/test/test_pkey_rsa.rb index 49e8ceac..c062a6a4 100644 --- a/test/test_pkey_rsa.rb +++ b/test/test_pkey_rsa.rb @@ -260,7 +260,7 @@ AwEAAQ== def test_read_private_key_pem_pw_exception pem = OpenSSL::TestUtils::TEST_KEY_RSA1024.to_pem(OpenSSL::Cipher.new('AES-128-CBC'), 'secret') # it raises an ArgumentError from PEM reading. The exception raised inside are ignored for now. - assert_raise(ArgumentError) do + assert_raise(OpenSSL::PKey::PKeyError) do OpenSSL::PKey.read(pem) do raise RuntimeError end @@ -285,7 +285,7 @@ AwEAAQ== end # password containing NUL byte pem = key.export(OpenSSL::Cipher.new('AES-128-CBC'), "pass\0wd") - assert_raise(ArgumentError) do + assert_raise(OpenSSL::PKey::PKeyError) do OpenSSL::PKey.read(pem, "pass") end key2 = OpenSSL::PKey.read(pem, "pass\0wd") |