<div dir="ltr">Hello,<br><br><br>Instead of using SSL_CTX_load_verify_locations with a file, we load the data from dll resource (multiple certs separated by -----BEGIN CERTIFICATE----- -----END CERTIFICATE-----):<br>    ...<br>    if(pdata = (BYTE *)LockResource( hglobal )) { // BYTE *pdata, hglobal is initialized with LoadResource<br>        if(cabio=BIO_new_mem_buf(pdata, -1)) { // create io to mem buffer<br>            PEM_read_bio_X509(cabio, &cacert, 0, NULL); // load cert to add to store later<br>            BIO_free_all(cabio);<br>        }<br>    }<br>    ...<br>everything seems good so far, data is correct, and cacert is initialized.  <br><br>Later we add it to the store:<br>    ...<br>    if(cacert) { <br>        X509_STORE *store = SSL_CTX_get_cert_store(ctx);  // ctx created earlier with SSL_CTX_new with TLSv1_2_method<br>        if(NULL != store) {<br>            if(!(res=X509_STORE_add_cert(store, cacert))) {<br>                // set some error info here and break out to free variables before exit<br>                break;<br>        }<br>        SSL_CTX_set_cert_store(ctx, store); // Not sure if we were working on store in ctx or on copy of it<br>        // if we dont set it back, when cert verified it produces X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY as if it never had the ca chain<br>        // if we do set it back, the verification crashes with memory access in X509_VERIFY_PARAM_inherit (x509_vpm.c)<br>    }<br>    ...<br><br>Is it that the PEM_read_bio_X509 can only load one cert at a time (why did it report success on load then)?<br>Or is it that only one cert at a time can be added to store? <br>Neither explains the crash (since all calls seemingly succeeded)<br><br>Any thoughts please?<br>Thank you</div>