diff --git a/src/proxy/tinymitm/ssl.cpp b/src/proxy/tinymitm/ssl.cpp index fd9d633..8cf3406 100644 --- a/src/proxy/tinymitm/ssl.cpp +++ b/src/proxy/tinymitm/ssl.cpp @@ -103,7 +103,17 @@ bool CertificateManager::installCertificate() bool success = false; 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); } CertFreeCertificateContext(certCtx);