2011-04-27 94 views
1

我在通過WiX安裝受密碼保護的PFX證書時遇到了一些問題。WiX:安裝受密碼保護的PFX證書的問題

我使用的是WiX 3.5.2519.0。

我包括PFX文件如下:

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

的$(var.ConfigSuffix)的值根據溶液的配置(例如, 「(調試)」, 「(階段)」)。對於「發佈」,它被設置爲一個空字符串。

我有各種解決方案配置,除了一個都使用非密碼保護的PFX證書,「Release」使用受密碼保護的PFX。我處理這個由「釋放」的配置只能有條件地定義$(var.PfxPassword),然後安裝證書,如下所示:

<?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?> 

我也試圖與替換「$(var.PfxPassword)」「 [PFXPASSWORD]「(已經在別處定義了這個)和純文本的實際密碼。在任何情況下,安裝失敗,以下日誌片段:

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. 

我相信錯誤0x80070056表示一個不正確的密碼,但我已經使用在PowerShell中Get-PfxCertificate來驗證我使用的密碼是正確的。

對於PFX文件不使用密碼的所有配置,安裝可以正常工作。

+0

密碼不包含任何可能需要轉義的字符,是嗎?例如[{]}等 – 2011-04-27 12:28:17

+0

否 - 只是純文本,例如「我的密碼」。 – 2011-04-27 13:01:10

+0

我遇到了同樣的問題。 「以管理員身份運行」解決了這個問題。 – kdmin 2016-09-13 19:10:58

回答

0

在互聯網上看到類似的問題elsewhere,它看起來像返回代碼3是一個「文件未找到」的問題。你確定正在包含正確的pfx文件嗎?