OpenSSL PEM_read_RSAPublicKey and PEM_read_RSA_PUBKEY crashes the program
<p>I have a public key in the form of</p>

<pre><code>-----BEGIN PUBLIC KEY-----
MIIB...
-----END PUBLIC KEY-----
</code></pre>

<p>that was created using OpenSSL. I attempt to load it into memory like such:</p>

<pre><code>FILE* file = fopen("public.pem","r");
if (file != nullptr)
{
   //This can be changed to this for the same results:
   //RSA* rsa = PEM_read_RSAPublicKey(file, nullptr, nullptr, nullptr);
   RSA* rsa = PEM_read_RSA_PUBKEY(file, nullptr, nullptr, nullptr);
   //etc...
}
</code></pre>

<p>Whenever it gets to the RSA* rsa =... line the program crashes. I have seen the other post for this and (as you can see) I have tried it the solution and it doesn't work.</p>

<p>I have tried using the BIO versions and the program does not crash but I do get the error "no start line".</p>

<p>Any ideas as to what can be causing this?</p>