@@ -814,6 +814,23 @@ static std::vector<X509*>& GetSystemStoreCACertificates() {
|
814 | 814 | return system_store_certs; |
815 | 815 | } |
816 | 816 | |
| 817 | +static void LoadSystemCACertificates(void* data) { |
| 818 | +GetSystemStoreCACertificates(); |
| 819 | +} |
| 820 | + |
| 821 | +static uv_thread_t system_ca_thread; |
| 822 | +static bool system_ca_thread_started = false; |
| 823 | +int LoadSystemCACertificatesOffThread() { |
| 824 | +// This is only run once during the initialization of the process, so |
| 825 | +// it is safe to use a static thread here. |
| 826 | +int r = |
| 827 | +uv_thread_create(&system_ca_thread, LoadSystemCACertificates, nullptr); |
| 828 | +if (r == 0) { |
| 829 | + system_ca_thread_started = true; |
| 830 | + } |
| 831 | +return r; |
| 832 | +} |
| 833 | + |
817 | 834 | static std::vector<X509*> InitializeExtraCACertificates() { |
818 | 835 | std::vector<X509*> extra_certs; |
819 | 836 | unsigned long err = LoadCertsFromFile( // NOLINT(runtime/int) |
@@ -925,6 +942,10 @@ void CleanupCachedRootCertificates() {
|
925 | 942 | X509_free(cert); |
926 | 943 | } |
927 | 944 | } |
| 945 | +if (system_ca_thread_started) { |
| 946 | +uv_thread_join(&system_ca_thread); |
| 947 | + system_ca_thread_started = false; |
| 948 | + } |
928 | 949 | } |
929 | 950 | |
930 | 951 | void GetBundledRootCertificates(const FunctionCallbackInfo<Value>& args) { |
|