File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed
Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -200,18 +200,14 @@ int SSL_CTX_use_certificate_chain(SSL_CTX* ctx,
200200void ReadSystemStoreCertificates (
201201 std::vector<std::string>* system_root_certificates) {
202202#ifdef _WIN32
203- const HCERTSTORE hStore = CertOpenSystemStoreW (0 , L" ROOT" );
204- CHECK_NE (hStore, nullptr );
205-
206- auto cleanup =
207- OnScopeLeave ([hStore]() { CHECK_EQ (CertCloseStore (hStore, 0 ), TRUE ); });
203+ CertStorePointer system_store;
208204
209205 PCCERT_CONTEXT certificate_context_ptr = nullptr ;
210206
211207 std::vector<X509*> system_root_certificates_X509;
212208
213209 while ((certificate_context_ptr = CertEnumCertificatesInStore (
214- hStore , certificate_context_ptr)) != nullptr ) {
210+ system_store. ref_ , certificate_context_ptr)) != nullptr ) {
215211 const DWORD certificate_buffer_size =
216212 CertGetNameStringW (certificate_context_ptr,
217213 CERT_NAME_SIMPLE_DISPLAY_TYPE,
Original file line number Diff line number Diff line change 99#include " memory_tracker.h"
1010#include " v8.h"
1111
12+ #ifdef _WIN32
13+ #include < wincrypt.h>
14+ #endif
15+
1216namespace node {
1317namespace crypto {
1418// A maxVersion of 0 means "any", but OpenSSL may support TLS versions that
1519// Node.js doesn't, so pin the max to what we do support.
1620constexpr int kMaxSupportedVersion = TLS1_3_VERSION;
1721
22+ #if _WIN32
23+ struct CertStorePointer {
24+ const HCERTSTORE ref_;
25+ CertStorePointer () : ref_(CertOpenSystemStoreW(0 , L" ROOT" )) {}
26+ ~CertStorePointer () { CHECK_EQ (CertCloseStore (ref_, 0 ), TRUE ); }
27+ };
28+ #endif
29+
1830void GetRootCertificates (
1931 const v8::FunctionCallbackInfo<v8::Value>& args);
2032
You can’t perform that action at this time.
0 commit comments