From 5f1bcd2d166d4de0f8081eed59d3c75e293c907e Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Thu, 20 Apr 2017 21:12:32 +1000 Subject: [PATCH] a first pass at the script to import the certificate for Windows --- atom/browser/ui/certificate_trust_win.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/atom/browser/ui/certificate_trust_win.cc b/atom/browser/ui/certificate_trust_win.cc index ecc7ccf6e4eb..18ef952e3612 100644 --- a/atom/browser/ui/certificate_trust_win.cc +++ b/atom/browser/ui/certificate_trust_win.cc @@ -5,6 +5,7 @@ #include "atom/browser/ui/certificate_trust.h" #include // windows.h must be included first +#include namespace certificate_trust { @@ -13,6 +14,24 @@ void ShowCertificateTrust(atom::NativeWindow* parent_window, const std::string& message, const ShowTrustCallback& callback) { + BOOL result = false; + HCERTSTORE hCertStore = NULL; + PCCERT_CONTEXT pCertContext = cert->CreateOSCertChainForCert(); + + // opening the Trusted Root Certificate store for the current user + hCertStore = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, NULL, CERT_SYSTEM_STORE_CURRENT_USER, L"Root"); + + // NOTE: this is a blocking call which displays a prompt to the user to + // confirm they trust this certificate + result = CertAddCertificateContextToStore(hCertStore, pCertContext, CERT_STORE_ADD_REPLACE_EXISTING, NULL); + + // close certificate store + CertCloseStore(hCertStore, CERT_CLOSE_STORE_FORCE_FLAG); + + // free certificate + CertFreeCertificateContext(pCertContext); + + &callback; } } // namespace certificate_trust