openssl 从内存加载ca证书


1 SSL_CTX* ctx = SSL_CTX_new(TLS_client_method());
2 BIO *root = BIO_new_mem_buf(buf, dataLen);
3 X509 *certX = d2i_X509_bio(root, NULL);  //DER格式
4 X509_STORE *certS = SSL_CTX_get_cert_store(ctx);
5 X509_STORE_add_cert(certS, certX);
6 X509_free(certX); 7 BIO_free(root);

 

普通证书

cbio = BIO_new_mem_buf(buf, bufLen);
cert = PEM_read_bio_X509(cbio, NULL, 0, NULL); //PEM格式
SSL_CTX_use_certificate(CTX, cert);

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM