Skip to content

Commit bab13ff

Browse files
committed
Taken from wixtoolset/wix3/pull/546, but have left out the explicit length
calculation from the pwzUniquePrefix string, and using this in the compare. Fixes #3976 Signed-off-by: Bevan Weiss <bevan.weiss@gmail.com>
1 parent 663d255 commit bab13ff

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/ext/Iis/ca/scacert.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,10 @@ static HRESULT FindExistingCertificate(
701701
PCCERT_CONTEXT pCertContext = NULL;
702702
BYTE* pbCertificate = NULL;
703703
DWORD cbCertificate = 0;
704+
LPWSTR pwzUniquePrefix = NULL;
705+
706+
hr = StrAllocFormatted(&pwzUniquePrefix, L"%s_wixCert_", wzName);
707+
ExitOnFailure(hr, "Failed to format unique name");
704708

705709
hCertStore = ::CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, NULL, dwStoreLocation | CERT_STORE_READONLY_FLAG, wzStore);
706710
MessageExitOnNullWithLastError(hCertStore, hr, msierrCERTFailedOpen, "Failed to open certificate store.");
@@ -713,7 +717,7 @@ static HRESULT FindExistingCertificate(
713717
DWORD cbFriendlyName = sizeof(wzFriendlyName);
714718

715719
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))
717721
{
718722
// If the certificate with matching friendly name is valid, let's use that.
719723
long lVerify = ::CertVerifyTimeValidity(NULL, pCertContext->pCertInfo);
@@ -739,6 +743,7 @@ static HRESULT FindExistingCertificate(
739743
pbCertificate = NULL;
740744

741745
LExit:
746+
ReleaseStr(pwzUniquePrefix);
742747
ReleaseMem(pbCertificate);
743748

744749
if (pCertContext)

0 commit comments

Comments
 (0)