OK, this is perplexing. I have a PEM-format RSA key in a character string
called _publicKey, with newlines between the header, key data, and trailer.
Like this:
-----BEGIN PUBLIC KEY----
MCwwHRTJKoZIhvcNAQEBBQADGwAwGAIRALPMoZzXMLIKhidteVfdR28CAwEAAQ==
-----END PUBLIC KEY-----
But PEM_read_bio_RSA_PUBKEY is still returning NULL, as in this:
BIO* bp = BIO_new_mem_buf(_publicKey, -1); // Create a new
memory buffer BIO.
RSA* pubKey = 0;
if(bp)
{
pubKey = PEM_read_bio_RSA_PUBKEY(bp, 0, 0, 0); // And read
the RSA key from it.
BIO_free(bp);
}
Does anybody see anything I'm doing wrong? I verified that the key string
matches what's in the PEM file that was generated on the command line.
Thanks!