【问题标题】:WiX: Problem installing password protected PFX certificateWiX:安装受密码保护的 PFX 证书时出现问题
【发布时间】:2011-08-13 19:31:25
【问题描述】:

我在通过 WiX 安装受密码保护的 PFX 证书时遇到了一些问题。

我使用的是 WiX 3.5.2519.0。

我包含一个 PFX 文件如下:

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

$(var.ConfigSuffix) 的值因解决方案配置而异(例如“(Debug)”、“(Stage)”)。对于“Release”,它被设置为一个空字符串。

我有各种解决方案配置,除了一个使用非密码保护的 PFX 证书,“Release”使用密码保护的 PFX。我通过仅在“Release”配置中有条件地定义 $(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]”(已在别处定义),并以纯文本形式替换实际密码。在任何情况下,安装都会失败并显示以下日志 sn-p:

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 文件不使用密码的所有配置,安装不会出现问题。

【问题讨论】:

  • 密码不包含任何可能需要转义的字符,是吗?例如[{]} 等
  • 否 - 只是纯文本,例如“我的密码”。
  • 我遇到了同样的问题。 “以管理员身份运行”已解决。

标签: wix certificate pfx


【解决方案1】:

在网上看了一个类似的问题elsewhere,看起来返回码3是一个“找不到文件”的问题。您确定包含正确的 pfx 文件吗?

【讨论】:

    猜你喜欢
    • 2017-12-19
    • 1970-01-01
    • 2019-01-01
    • 1970-01-01
    • 2016-01-26
    • 2010-11-24
    • 2012-09-06
    • 2016-09-14
    相关资源
    最近更新 更多