Skip to content

Commit e28e80d

Browse files
davidbengibfahn
authored andcommitted
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: #16130 Backport-PR-URL: #18622 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rod Vagg <rod@vagg.org>
1 parent 56401a4 commit e28e80d

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/node_crypto.cc

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -571,19 +571,12 @@ void SecureContext::SetKey(const FunctionCallbackInfo<Value>& args) {
571571

572572

573573
int SSL_CTX_get_issuer(SSL_CTX* ctx, X509* cert, X509** issuer) {
574-
int ret;
575-
576574
X509_STORE* store = SSL_CTX_get_cert_store(ctx);
577-
X509_STORE_CTX store_ctx;
578-
579-
ret = X509_STORE_CTX_init(&store_ctx, store, nullptr, nullptr);
580-
if (!ret)
581-
goto end;
582-
583-
ret = X509_STORE_CTX_get1_issuer(issuer, &store_ctx, cert);
584-
X509_STORE_CTX_cleanup(&store_ctx);
585-
586-
end:
575+
X509_STORE_CTX* store_ctx = X509_STORE_CTX_new();
576+
int ret = store_ctx != nullptr &&
577+
X509_STORE_CTX_init(store_ctx, store, nullptr, nullptr) == 1 &&
578+
X509_STORE_CTX_get1_issuer(issuer, store_ctx, cert) == 1;
579+
X509_STORE_CTX_free(store_ctx);
587580
return ret;
588581
}
589582

0 commit comments

Comments
 (0)