File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed
Expand file tree Collapse file tree 2 files changed +15
-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 < Windows.h>
14+ #include < wincrypt.h>
15+ #endif
16+
1217namespace node {
1318namespace crypto {
1419// A maxVersion of 0 means "any", but OpenSSL may support TLS versions that
1520// Node.js doesn't, so pin the max to what we do support.
1621constexpr int kMaxSupportedVersion = TLS1_3_VERSION;
1722
23+ #if _WIN32
24+ struct CertStorePointer {
25+ const HCERTSTORE ref_;
26+ CertStorePointer () : ref_(CertOpenSystemStoreW(0 , L" ROOT" )) {}
27+ ~CertStorePointer () { CHECK_EQ (CertCloseStore (ref_, 0 ), TRUE ); }
28+ };
29+ #endif
30+
1831void GetRootCertificates (
1932 const v8::FunctionCallbackInfo<v8::Value>& args);
2033
You can’t perform that action at this time.
0 commit comments