Skip to content

Commit

Permalink
crypto: check CI failures
Browse files Browse the repository at this point in the history
  • Loading branch information
twitharshil committed Oct 20, 2022
1 parent fce1743 commit 52fbf17
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/crypto/crypto_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,14 @@ int SSL_CTX_use_certificate_chain(SSL_CTX* ctx,
void ReadSystemStoreCertificates(
std::vector<std::string>* system_root_certificates) {
#ifdef _WIN32
const HCERTSTORE hStore = CertOpenSystemStoreW(0, L"ROOT");
CHECK_NE(hStore, nullptr);

auto cleanup =
OnScopeLeave([hStore]() { CHECK_EQ(CertCloseStore(hStore, 0), TRUE); });
CertStorePointer system_store;

PCCERT_CONTEXT certificate_context_ptr = nullptr;

std::vector<X509*> system_root_certificates_X509;

while ((certificate_context_ptr = CertEnumCertificatesInStore(
hStore, certificate_context_ptr)) != nullptr) {
system_store.ref_, certificate_context_ptr)) != nullptr) {
const DWORD certificate_buffer_size =
CertGetNameStringW(certificate_context_ptr,
CERT_NAME_SIMPLE_DISPLAY_TYPE,
Expand Down
13 changes: 13 additions & 0 deletions src/crypto/crypto_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,25 @@
#include "memory_tracker.h"
#include "v8.h"

#ifdef _WIN32
#include <Windows.h>
#include <wincrypt.h>
#endif

namespace node {
namespace crypto {
// A maxVersion of 0 means "any", but OpenSSL may support TLS versions that
// Node.js doesn't, so pin the max to what we do support.
constexpr int kMaxSupportedVersion = TLS1_3_VERSION;

#if _WIN32
struct CertStorePointer {
const HCERTSTORE ref_;
CertStorePointer() : ref_(CertOpenSystemStoreW(0, L"ROOT")) {}
~CertStorePointer() { CHECK_EQ(CertCloseStore(ref_, 0), TRUE); }
};
#endif

void GetRootCertificates(
const v8::FunctionCallbackInfo<v8::Value>& args);

Expand Down

0 comments on commit 52fbf17

Please sign in to comment.