title: Reading Public/Private Key from Memory with OpenSSL
body: <p>I am using Public/Private Keys in my project to encrypt/decrypt some data.</p>
  
  <p>I am hosting a public key ("public.pem") on a server.</p>
  
  <p>"public.pem" looks like this:</p>
  
  <pre><code>-----BEGIN PUBLIC KEY-----
  .....
  .....
  -----END PUBLIC KEY-----
  </code></pre>
  
  <p>I wrote a client side that downloads this public key and save it to disk and then calls OpenSSL's PEM_read_RSA_PUBKEY() with a File descriptor to that file.
  This operation works great and the result is an RSA object that is ready for encryption.</p>
  
  <p>I would like to avoid writing the public key to disk each time (since i have the buffer in memory already).</p>
  
  <p>How can i do the same operation without saving the buffer to disk?
  I noticed a function called: PEM_read_bio_RSAPublicKey() but i am not sure of it's usage of BIO structure. Am I on the right path?</p>
  
  <p>So the real question would be: How do I read a public/private key to an RSA object straight from memory and not from a file descriptor.</p>