Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
class method
OpenSSL::PKey.read
(::String | ::IO pem, ?::String password) -> ::OpenSSL::PKey::PKey
OpenSSL::PKey.read(string [, pwd ]) → PKey
OpenSSL::PKey.read(io [, pwd ]) → PKey
ext/openssl/ossl_pkey.c
View on GitHub ↗
static VALUE
ossl_pkey_new_from_data(int argc, VALUE *argv, VALUE self)
{
EVP_PKEY *pkey;
BIO *bio;
VALUE data, pass;
rb_scan_args(argc, argv, "11", &data, &pass);
bio = ossl_obj2bio(&data);
pkey = ossl_pkey_read_generic(bio, ossl_pem_passwd_value(pass));
BIO_free(bio);
if (!pkey)
ossl_raise(ePKeyError, "Could not parse PKey");
return ossl_pkey_new(pkey);
}
Reads a DER or PEM encoded string from string or io and returns an instance of the appropriate PKey class.
Parameters
-
string is a DER- or PEM-encoded string containing an arbitrary private or public key.
-
io is an instance of
IOcontaining a DER- or PEM-encoded arbitrary private or public key. -
pwd is an optional password in case string or io is an encrypted PEM resource.