From f644ba56a335cdf42361428e5f0533ede46ad8d5 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Mon, 24 Apr 2017 11:49:55 +1000 Subject: [PATCH] clean up the code a bit --- atom/browser/ui/certificate_trust_win.cc | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/atom/browser/ui/certificate_trust_win.cc b/atom/browser/ui/certificate_trust_win.cc index 6d5eeb384da5..49d74367a0f3 100644 --- a/atom/browser/ui/certificate_trust_win.cc +++ b/atom/browser/ui/certificate_trust_win.cc @@ -16,21 +16,25 @@ void ShowCertificateTrust(atom::NativeWindow* parent_window, const scoped_refptr& cert, 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( + auto hCertStore = CertOpenStore( CERT_STORE_PROV_SYSTEM, 0, NULL, CERT_SYSTEM_STORE_CURRENT_USER, + // installing into Trusted Root Certificate Authorities, not Personal L"Root"); - // NOTE: this is a blocking call which displays a prompt to the user to - // confirm they trust this certificate - result = CertAddCertificateContextToStore( + if (hCertStore == NULL) { + callback.Run(); + return; + } + + auto pCertContext = cert->CreateOSCertChainForCert(); + + // This is a blocking call which displays a prompt to the user to confirm + // they trust this certificate + auto result = CertAddCertificateContextToStore( hCertStore, pCertContext, CERT_STORE_ADD_REPLACE_EXISTING,