Unable to load RSA public key for signature verification

Michael Wojcik Michael.Wojcik at microfocus.com
Thu Apr 13 17:28:34 UTC 2023


> From: openssl-users <openssl-users-bounces at openssl.org> On Behalf Of Juan Pablo Garibotti Arias
> Sent: Thursday, 13 April, 2023 10:42

> RsaPtr PublicKey(FILE* keyFile) {
>  char pass[] = "";
 >  return RsaPtr{PEM_read_RSAPublicKey(keyFile, nullptr, nullptr, pass)};
> }

> int main() {
>  constexpr auto pubKey = "-----BEGIN PUBLIC KEY-----\n"

A quick look at the source shows PEM_read_RSAPublicKey wants PEM_STRING_RSA_PUBLIC, which is "RSA PUBLIC KEY". So that function only supports PEM objects with the start line "-----BEGIN RSA PUBLIC KEY-----".

OpenSSL supports multiple PEM formats for RSA keys. I'm trying to recall the details -- I think there's an old OpenSSL format and a later standard format, maybe?

Try PEM_read_RSA_PUBKEY instead.

-- 
Michael Wojcik



More information about the openssl-users mailing list