clean up the code a bit
This commit is contained in:
parent
253a4b0114
commit
f644ba56a3
1 changed files with 12 additions and 8 deletions
|
@ -16,21 +16,25 @@ void ShowCertificateTrust(atom::NativeWindow* parent_window,
|
||||||
const scoped_refptr<net::X509Certificate>& cert,
|
const scoped_refptr<net::X509Certificate>& cert,
|
||||||
const std::string& message,
|
const std::string& message,
|
||||||
const ShowTrustCallback& callback) {
|
const ShowTrustCallback& callback) {
|
||||||
BOOL result = false;
|
|
||||||
HCERTSTORE hCertStore = NULL;
|
|
||||||
PCCERT_CONTEXT pCertContext = cert->CreateOSCertChainForCert();
|
|
||||||
|
|
||||||
// opening the Trusted Root Certificate store for the current user
|
// opening the Trusted Root Certificate store for the current user
|
||||||
hCertStore = CertOpenStore(
|
auto hCertStore = CertOpenStore(
|
||||||
CERT_STORE_PROV_SYSTEM,
|
CERT_STORE_PROV_SYSTEM,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
CERT_SYSTEM_STORE_CURRENT_USER,
|
CERT_SYSTEM_STORE_CURRENT_USER,
|
||||||
|
// installing into Trusted Root Certificate Authorities, not Personal
|
||||||
L"Root");
|
L"Root");
|
||||||
|
|
||||||
// NOTE: this is a blocking call which displays a prompt to the user to
|
if (hCertStore == NULL) {
|
||||||
// confirm they trust this certificate
|
callback.Run();
|
||||||
result = CertAddCertificateContextToStore(
|
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,
|
hCertStore,
|
||||||
pCertContext,
|
pCertContext,
|
||||||
CERT_STORE_ADD_REPLACE_EXISTING,
|
CERT_STORE_ADD_REPLACE_EXISTING,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue