/gist:574388
Created Sep 10, 2010
How to add a certificate from buffer in OpenSSL
| X509 *cert; | |
| char *zCert; | |
| BIO *mem; | |
| zCert = // get your certificate text buffer here (C string with certificate in PEM format) | |
| mem = BIO_new(BIO_s_mem()); | |
| BIO_puts(mem, zCert); | |
| cert = PEM_read_bio_X509(mem, NULL, 0, NULL); | |
| free(zCert); | |
| BIO_free(mem); | |
| // set certificate to sslCtx | |
| X509_STORE_add_cert(SSL_CTX_get_cert_store(sslCtx), cert); |
This comment has been minimized.
This comment has been minimized.
emka002
commented
Apr 29, 2015
|
Great! Many thanks, thats exactly what i'm looking for. |
This comment has been minimized.
This comment has been minimized.
LesnyRumcajs
commented
Jan 12, 2016
|
I wonder how many other occult functions does OpenSSL have - the official documentation doesn't say a word about it even though it's extremely useful. Thanks, my code shrinked by many lines! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
skabbes commentedApr 8, 2014
for anyone else who comes looking, if you have more than one pem file in zCert, you'll need to loop.