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);