[ruby/openssl] ns_spki: fix exception class in OpenSSL::Netscape::SPKI#to_der

It should raise OpenSSL::Netscape::SPKIError instead of
OpenSSL::X509::CertificateError.

No test cases covered this because it only occurs in exceptional
cases, such as memory allocation failure.

https://github.com/ruby/openssl/commit/527b6101d1
This commit is contained in:
Kazuki Yamaguchi 2024-10-30 03:26:52 +09:00 committed by git
parent b207b956c1
commit 3656c1db29

View File

@ -115,11 +115,11 @@ ossl_spki_to_der(VALUE self)
GetSPKI(self, spki);
if ((len = i2d_NETSCAPE_SPKI(spki, NULL)) <= 0)
ossl_raise(eX509CertError, NULL);
ossl_raise(eSPKIError, "i2d_NETSCAPE_SPKI");
str = rb_str_new(0, len);
p = (unsigned char *)RSTRING_PTR(str);
if (i2d_NETSCAPE_SPKI(spki, &p) <= 0)
ossl_raise(eX509CertError, NULL);
ossl_raise(eSPKIError, "i2d_NETSCAPE_SPKI");
ossl_str_adjust(str, p);
return str;