diff --git a/platform/src/ssl_fetch_cert.cpp b/platform/src/ssl_fetch_cert.cpp index dc9ddd7..58927bb 100644 --- a/platform/src/ssl_fetch_cert.cpp +++ b/platform/src/ssl_fetch_cert.cpp @@ -103,6 +103,8 @@ void ssl_fetch_trusted_cert_from_chain(STACK_OF(X509) * cert_chain, X509_STORE * obj->type = X509_LU_X509; obj->data.x509 = (X509 *)cert; + X509_OBJECT_up_ref_count(obj); + // not in trusted store if (X509_OBJECT_retrieve_match(X509_STORE_get0_objects(trusted_store), obj) == NULL) { @@ -113,6 +115,9 @@ void ssl_fetch_trusted_cert_from_chain(STACK_OF(X509) * cert_chain, X509_STORE * { ret = 1; } + // https://man.openbsd.org/X509_OBJECT_up_ref_count.3 + // https://groups.google.com/forum/m/#!msg/mailing.openssl.dev/9-PNIcR91Qo/FqnBOr8sBAAJ + //X509_OBJECT_free_contents(obj); X509_OBJECT_free(obj); subj = ssl_x509_subject(cert);