Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

OpenSSL::PKey::PKey#private_to_der

pkey.private_to_der → string
pkey.private_to_der(cipher, password) → string

Serializes the private key to DER-encoded PKCS #8 format. If called without arguments, unencrypted PKCS #8 PrivateKeyInfo format is used. If called with a cipher name and a password, PKCS #8 EncryptedPrivateKeyInfo format with PBES2 encryption scheme is used.

See also #oid #private_to_pem #inspect #public_to_der also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0