fix: check for already existing cert
This commit is contained in:
@@ -103,7 +103,17 @@ bool CertificateManager::installCertificate()
|
|||||||
bool success = false;
|
bool success = false;
|
||||||
if (rootStore)
|
if (rootStore)
|
||||||
{
|
{
|
||||||
success = CertAddCertificateContextToStore(rootStore, certCtx, CERT_STORE_ADD_REPLACE_EXISTING, NULL);
|
PCCERT_CONTEXT existingCert = CertFindCertificateInStore(rootStore, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0,
|
||||||
|
CERT_FIND_EXISTING, certCtx, NULL);
|
||||||
|
if (existingCert)
|
||||||
|
{
|
||||||
|
CertFreeCertificateContext(existingCert);
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
success = CertAddCertificateContextToStore(rootStore, certCtx, CERT_STORE_ADD_REPLACE_EXISTING, NULL);
|
||||||
|
}
|
||||||
CertCloseStore(rootStore, 0);
|
CertCloseStore(rootStore, 0);
|
||||||
}
|
}
|
||||||
CertFreeCertificateContext(certCtx);
|
CertFreeCertificateContext(certCtx);
|
||||||
|
|||||||
Reference in New Issue
Block a user