Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

OpenSSL::PKey::PKey#public_to_pem

() -> ::String
pkey.public_to_pem → string

Serializes the public key to PEM-encoded X.509 SubjectPublicKeyInfo format.

A PEM-encoded key will look like:

-----BEGIN PUBLIC KEY-----
[...]
-----END PUBLIC KEY-----