@@ -701,6 +701,10 @@ static HRESULT FindExistingCertificate(
701
701
PCCERT_CONTEXT pCertContext = NULL ;
702
702
BYTE* pbCertificate = NULL ;
703
703
DWORD cbCertificate = 0 ;
704
+ LPWSTR pwzUniquePrefix = NULL ;
705
+
706
+ hr = StrAllocFormatted (&pwzUniquePrefix, L" %s_wixCert_" , wzName);
707
+ ExitOnFailure (hr, " Failed to format unique name" );
704
708
705
709
hCertStore = ::CertOpenStore (CERT_STORE_PROV_SYSTEM, 0 , NULL , dwStoreLocation | CERT_STORE_READONLY_FLAG, wzStore);
706
710
MessageExitOnNullWithLastError (hCertStore, hr, msierrCERTFailedOpen, " Failed to open certificate store." );
@@ -713,7 +717,7 @@ static HRESULT FindExistingCertificate(
713
717
DWORD cbFriendlyName = sizeof (wzFriendlyName);
714
718
715
719
if (::CertGetCertificateContextProperty (pCertContext, CERT_FRIENDLY_NAME_PROP_ID, reinterpret_cast <BYTE*>(wzFriendlyName), &cbFriendlyName) &&
716
- CSTR_EQUAL == ::CompareStringW (LOCALE_SYSTEM_DEFAULT, 0 , wzName , -1 , wzFriendlyName, -1 ))
720
+ CSTR_EQUAL == ::CompareStringW (LOCALE_SYSTEM_DEFAULT, 0 , pwzUniquePrefix , -1 , wzFriendlyName, -1 ))
717
721
{
718
722
// If the certificate with matching friendly name is valid, let's use that.
719
723
long lVerify = ::CertVerifyTimeValidity (NULL , pCertContext->pCertInfo );
@@ -739,6 +743,7 @@ static HRESULT FindExistingCertificate(
739
743
pbCertificate = NULL ;
740
744
741
745
LExit:
746
+ ReleaseStr (pwzUniquePrefix);
742
747
ReleaseMem (pbCertificate);
743
748
744
749
if (pCertContext)
0 commit comments