> From: openssl-users <openssl-users-bounces@xxxxxxxxxxx> 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