зеркало из https://github.com/github/ruby.git
[ruby/openssl] pkey: have PKey.read parse PEM-encoded DHParameter
Try PEM_read_bio_Parameters(). Only PEM format is supported at the moment since corresponding d2i_* functions are not provided by OpenSSL. https://github.com/ruby/openssl/commit/867e5c021b
This commit is contained in:
Родитель
c157f6e787
Коммит
efad0166c6
|
@ -178,6 +178,9 @@ ossl_pkey_new_from_data(int argc, VALUE *argv, VALUE self)
|
|||
OSSL_BIO_reset(bio);
|
||||
if ((pkey = PEM_read_bio_PUBKEY(bio, NULL, NULL, NULL)))
|
||||
goto ok;
|
||||
OSSL_BIO_reset(bio);
|
||||
if ((pkey = PEM_read_bio_Parameters(bio, NULL)))
|
||||
goto ok;
|
||||
|
||||
BIO_free(bio);
|
||||
ossl_raise(ePKeyError, "Could not parse PKey");
|
||||
|
|
|
@ -36,6 +36,8 @@ class OpenSSL::TestPKeyDH < OpenSSL::PKeyTestCase
|
|||
EOF
|
||||
key = OpenSSL::PKey::DH.new(pem)
|
||||
assert_same_dh dup_public(dh1024), key
|
||||
key = OpenSSL::PKey.read(pem)
|
||||
assert_same_dh dup_public(dh1024), key
|
||||
|
||||
assert_equal asn1.to_der, dh1024.to_der
|
||||
assert_equal pem, dh1024.export
|
||||
|
|
|
@ -42,9 +42,6 @@ module OpenSSL::TestUtils
|
|||
|
||||
def pkey(name)
|
||||
OpenSSL::PKey.read(read_file("pkey", name))
|
||||
rescue OpenSSL::PKey::PKeyError
|
||||
# TODO: DH parameters can be read by OpenSSL::PKey.read atm
|
||||
OpenSSL::PKey::DH.new(read_file("pkey", name))
|
||||
end
|
||||
|
||||
def read_file(category, name)
|
||||
|
|
Загрузка…
Ссылка в новой задаче