crypto: use X509_STORE_CTX_new

In OpenSSL 1.1.0, X509_STORE_CTX is opaque and thus cannot be
stack-allocated. This works in OpenSSL 1.1.0 and 1.0.2. Adapted from PR

PR-URL: https://github.com/nodejs/node/pull/16130
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rod Vagg <rod@vagg.org>
This commit is contained in:
David Benjamin authored and Evan Lucas committed 2017-11-13 07:59:42 -06:00
1 parent b42013c31e
commit 8da4983cb4
1 file changed
+5 -12
+5 -12
View File
@@ -572,19 +572,12 @@ void SecureContext::SetKey(const FunctionCallbackInfo<Value>& args) {
int SSL_CTX_get_issuer(SSL_CTX* ctx, X509* cert, X509** issuer) {
int ret;
X509_STORE* store = SSL_CTX_get_cert_store(ctx);
X509_STORE_CTX store_ctx;
ret = X509_STORE_CTX_init(&store_ctx, store, nullptr, nullptr);
if (!ret)
goto end;
ret = X509_STORE_CTX_get1_issuer(issuer, &store_ctx, cert);
X509_STORE_CTX_cleanup(&store_ctx);
end:
X509_STORE_CTX* store_ctx = X509_STORE_CTX_new();
int ret = store_ctx != nullptr &&
X509_STORE_CTX_init(store_ctx, store, nullptr, nullptr) == 1 &&
X509_STORE_CTX_get1_issuer(issuer, store_ctx, cert) == 1;
X509_STORE_CTX_free(store_ctx);
return ret;
}