Skip to content

Commit 19a7b1e

Browse files
joyeecheungaduh95
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 095e7a8 commit 19a7b1e

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
@@ -836,6 +836,23 @@ static std::vector<X509*>& GetExtraCACertificates() {
836836
}
837837

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

874+
// --use-openssl-ca is mutually exclusive with --use-bundled-ca and
875+
// --use-system-ca. If it's set, no need to optimize with off-thread
876+
// loading.
857877
{
858878
Mutex::ScopedLock cli_lock(node::per_process::cli_options_mutex);
859-
if (!per_process::cli_options->use_system_ca) {
879+
if (!per_process::cli_options->ssl_openssl_cert_store) {
860880
return;
861881
}
862882
}

0 commit comments

Comments
 (0)