Skip to content

Commit 5082ab3

Browse files
committed
crypto: check CI failures
1 parent fce1743 commit 5082ab3

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,24 @@
99
#include "memory_tracker.h"
1010
#include "v8.h"
1111

12+
#ifdef _WIN32
13+
#include <wincrypt.h>
14+
#endif
15+
1216
namespace node {
1317
namespace 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.
1620
constexpr 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+
1830
void GetRootCertificates(
1931
const v8::FunctionCallbackInfo<v8::Value>& args);
2032

0 commit comments

Comments
 (0)