Skip to content

Commit

Permalink
ns_spki: fix exception class in OpenSSL::Netscape::SPKI#to_der
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rhenium committed Nov 12, 2024
1 parent b1f6a04 commit 527b610
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ext/openssl/ossl_ns_spki.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 527b610

Please sign in to comment.