views:

41

answers:

2

Hi, I have a server which would listen on HTTPS using OpenSSL. For this, I have to provide the certificate to use. However, the current implementation uses a filename to be provided to OpenSSL API. I want the cert information to be read from memory, so that I don't have to ship the certificate file opening. I tried to google, but didn't come up with any options. Is is possible? Are there any samples/tutorials already available on WEB which I can go through? Any other pointers/help.

PS: The code is written in C.

+1  A: 
unsigned char *cert_data = (....);
int cert_len = (....);

X509 *cert = d2i_X509(NULL, &cert_data, cert_len);
SSL_CTX_use_certificate(ctx, cert);

unsigned char *pkey_data = /* ... */;
int pkey_len = /* ... */;

RSA *pkey = d2i_RSAPrivateKey(NULL, &pkey_data, pkey_len);
SSL_CTX_use_RSAPrivateKey(ctx, pkey);

Don't forget & before cert_data and pkey_data - and note that OpenSSL modifies these pointers.

blaze
A: 
Karthik