Skip to content

Commit 6790093

Browse files
joyeecheungtargos
authored andcommitted
tls: load bundled and extra certificates off-thread
This patch makes the certificate pre-loading thread load the bundled and extra certificates from the other thread as well. PR-URL: #59856 Reviewed-By: James M Snell <[email protected]>
1 parent f5d3f91 commit 6790093

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/crypto/crypto_context.cc

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,23 @@ static std::vector<X509*>& GetExtraCACertificates() {
838838
}
839839

840840
static void LoadCACertificates(void* data) {
841+
per_process::Debug(DebugCategory::CRYPTO,
842+
"Started loading bundled root certificates off-thread\n");
843+
GetBundledRootCertificates();
844+
845+
if (!extra_root_certs_file.empty()) {
846+
per_process::Debug(DebugCategory::CRYPTO,
847+
"Started loading extra root certificates off-thread\n");
848+
GetExtraCACertificates();
849+
}
850+
851+
{
852+
Mutex::ScopedLock cli_lock(node::per_process::cli_options_mutex);
853+
if (!per_process::cli_options->use_system_ca) {
854+
return;
855+
}
856+
}
857+
841858
per_process::Debug(DebugCategory::CRYPTO,
842859
"Started loading system root certificates off-thread\n");
843860
GetSystemStoreCACertificates();
@@ -856,9 +873,12 @@ void StartLoadingCertificatesOffThread(
856873
// Get*CACertificates() functions has a function-local static and any
857874
// actual user of it will wait for that to complete initialization.
858875

876+
// --use-openssl-ca is mutually exclusive with --use-bundled-ca and
877+
// --use-system-ca. If it's set, no need to optimize with off-thread
878+
// loading.
859879
{
860880
Mutex::ScopedLock cli_lock(node::per_process::cli_options_mutex);
861-
if (!per_process::cli_options->use_system_ca) {
881+
if (!per_process::cli_options->ssl_openssl_cert_store) {
862882
return;
863883
}
864884
}

0 commit comments

Comments
 (0)