Skip to content

Commit f61b98f

Browse files
committed
src: modify SecureContext::SetCACert to not use root_certs
1 parent 8253290 commit f61b98f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/crypto/crypto_context.cc

+5-3
Original file line numberDiff line numberDiff line change
@@ -785,9 +785,11 @@ void SecureContext::SetCACert(const BIOPointer& bio) {
785785
if (!bio) return;
786786
while (X509Pointer x509 = X509Pointer(PEM_read_bio_X509_AUX(
787787
bio.get(), nullptr, NoPasswordCallback, nullptr))) {
788-
CHECK_EQ(1,
789-
X509_STORE_add_cert(GetCertStoreOwnedByThisSecureContext(),
790-
x509.get()));
788+
// Get the existing cert store from the SSL context
789+
// instead of GetCertStoreOwnedByThisSecureContext()
790+
// to avoid creating X509_STORE based on root_certs, which is very slow
791+
CHECK_EQ(
792+
1, X509_STORE_add_cert(SSL_CTX_get_cert_store(ctx_.get()), x509.get()));
791793
CHECK_EQ(1, SSL_CTX_add_client_CA(ctx_.get(), x509.get()));
792794
}
793795
}

0 commit comments

Comments
 (0)