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::EC#to_der
key.to_der => String
ext/openssl/ossl_pkey_ec.c
View on GitHub ↗
static VALUE
ossl_ec_key_to_der(VALUE self)
{
EC_KEY *ec;
GetEC(self, ec);
if (EC_KEY_get0_public_key(ec) == NULL)
ossl_raise(eECError, "can't export - no public key set");
if (EC_KEY_get0_private_key(ec))
return ossl_pkey_export_traditional(0, NULL, self, 1);
else
return ossl_pkey_export_spki(self, 1);
}
See the OpenSSL documentation for i2d_ECPrivateKey_bio()