Skip to content

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

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 IO containing 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.

See also .new_raw_public_key .new_raw_private_key also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0