c - Read Certificate files from memory instead of file OpenSSL -
c - Read Certificate files from memory instead of file OpenSSL -
i have server hear on https using openssl. this, have provide certificate use. however, current implementation uses filename provided openssl api. want cert info read memory, don't have ship certificate file opening. tried google, didn't come options. is possible? there samples/tutorials available on web can go through? other pointers/help.
ps: code written in c.
the next code did job me:
ssl_ctx *ctx; x509 *cert = null; rsa *rsa = null; bio *cbio, *kbio; const char *cert_buffer = ""; const char *key_buffer = ""; cbio = bio_new_mem_buf((void*)cert_buffer, -1); cert = pem_read_bio_x509(cbio, null, 0, null); assert(cert != null); ssl_ctx_use_certificate(ctx, cert); kbio = bio_new_mem_buf((void*)key_buffer, -1); rsa = pem_read_bio_rsaprivatekey(kbio, null, 0, null); assert(rsa != null); ssl_ctx_use_rsaprivatekey(ctx, rsa);
c openssl certificate
Comments
Post a Comment