I am using Public/Private Keys in my project to encrypt/decrypt some data.

I am hosting a public key ("public.pem") on a server.

"public.pem" looks like this:

```
-----BEGIN PUBLIC KEY-----
.....
.....
-----END PUBLIC KEY-----

```

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.

I would like to avoid writing the public key to disk each time (since i have the buffer in memory already).

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?

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.