Skip to content

Commit

Permalink
crypto: use X509_STORE_CTX_new
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: Rod Vagg <[email protected]>
  • Loading branch information
davidben authored and gibfahn committed Feb 18, 2018
1 parent 56401a4 commit e28e80d
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -571,19 +571,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;
}

Expand Down

0 comments on commit e28e80d

Please sign in to comment.