Skip to content

Commit 52fbf17

Browse files
committed
crypto: check CI failures
1 parent fce1743 commit 52fbf17

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/crypto/crypto_context.cc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,18 +200,14 @@ int SSL_CTX_use_certificate_chain(SSL_CTX* ctx,
200200
void 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,

src/crypto/crypto_context.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,25 @@
99
#include "memory_tracker.h"
1010
#include "v8.h"
1111

12+
#ifdef _WIN32
13+
#include <Windows.h>
14+
#include <wincrypt.h>
15+
#endif
16+
1217
namespace node {
1318
namespace 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.
1621
constexpr 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+
1831
void GetRootCertificates(
1932
const v8::FunctionCallbackInfo<v8::Value>& args);
2033

0 commit comments

Comments
 (0)