WiX: Problem installing password protected PFX certificate

1

I'm having some trouble getting a password protected PFX certificate to install through WiX.

I'm using WiX 3.5.2519.0.

I include a PFX file as follows:

<Binary Id="My.Binary"
 SourceFile="$(var.ProjectDir)MyProject$(var.ConfigSuffix).pfx" />

The value of $(var.ConfigSuffix) varies based on solution configuration (e.g. " (Debug)", " (Stage)"). For "Release", it is set to an empty string.

I have various solution configurations, all but one use a non-password protected PFX certificate, "Release" uses a password protected PFX. I deal with this by conditionally defining $(var.PfxPassword) in "Release" configuration only, and then installing the certificate as follows:

<?ifdef $(var.PfxPassword) ?>
    <iis:Certificate
    Id="My.Certificate"
    StoreName="root"
    Overwrite="yes"
    Name="My Web Site$(var.ConfigSuffix)"
    Request="no"
    BinaryKey="MyCertificate.Binary"
    StoreLocation="localMachine"
    PFXPassword="$(var.PfxPassword)" />
<?else?>
    <iis:Certificate
    Id="My.Certificate" 
    StoreName="root" 
    Overwrite="yes" 
    Name="My Web Site$(var.ConfigSuffix)" 
    Request="no" 
    BinaryKey="MyCertificate.Binary" 
    StoreLocation="localMachine" />
<?endif?>

I have also tried replacing "$(var.PfxPassword)" with "[PFXPASSWORD]" (having defined this elsewhere), and the actual password in plain text. In every case, installation fails with the following log snippet:

Action start 12:29:02: InstallCertificates.
InstallCertificates:  Error 0x80070056: Failed to open PFX file.
InstallCertificates:  Error 0x80070056: Failed to get SHA1 hash of certificate.
InstallCertificates:  Error 0x80070056: Failed to resolve certificate: LinnRecords.Certificate
CustomAction InstallCertificates returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 12:29:02: InstallCertificates. Return value 3.

I believe error 0x80070056 indicates an incorrect password, however I have used the Get-PfxCertificate in PowerShell to verify that the password I am using is correct.

For all configurations where the PFX file does not use a password, the installation works without issue.

wix
certificate
pfx
asked on Stack Overflow Apr 27, 2011 by Jim Liddell • edited Nov 9, 2018 by Cœur

1 Answer

0

Looking at a similar problem elsewhere on the internet, it looks like return code 3 is a "File not found" problem. Are you sure the correct pfx file is being included?

answered on Stack Overflow May 5, 2011 by colin.t.welch

User contributions licensed under CC BY-SA 3.0