Skip to content

Commit c58197f

Browse files
committed
crypto: add pfx certs as CA certs too
According to documentation all certificates specified in `pfx` option should be treated as a CA certificates too. While it doesn't seem to be logically correct to me, we can't afford to break API stability at this point. Fix: nodejs#5100
1 parent 25751be commit c58197f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/node_crypto.cc

+11
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,17 @@ void SecureContext::LoadPKCS12(const FunctionCallbackInfo<Value>& args) {
982982
&sc->cert_,
983983
&sc->issuer_) &&
984984
SSL_CTX_use_PrivateKey(sc->ctx_, pkey)) {
985+
// Add CA certs too
986+
for (int i = 0; i < sk_X509_num(extra_certs); i++) {
987+
X509* ca = sk_X509_value(extra_certs, i);
988+
989+
if (!sc->ca_store_) {
990+
sc->ca_store_ = X509_STORE_new();
991+
SSL_CTX_set_cert_store(sc->ctx_, sc->ca_store_);
992+
}
993+
X509_STORE_add_cert(sc->ca_store_, ca);
994+
SSL_CTX_add_client_CA(sc->ctx_, ca);
995+
}
985996
ret = true;
986997
}
987998

0 commit comments

Comments
 (0)