WiX:安装受密码保护的 PFX 证书时出现问题

发布于 2024-11-03 08:12:24 字数 1836 浏览 1 评论 0 原文

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

我正在使用 WiX 3.5.2519.0。

我包含一个 PFX 文件,如下所示:

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

$(var.ConfigSuffix) 的值根据解决方案配置而变化(例如“(调试)”、“(阶段)”)。对于“Release”,它被设置为空字符串。

我有各种解决方案配置,除了一个之外,所有配置都使用非密码保护的 PFX 证书,“发布”使用密码保护的 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]”(已定义其他地方),以及纯文本形式的实际密码。在每种情况下,安装都会失败并显示以下日志片段:

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 表示密码不正确,但是我使用了 Get-PfxCertificate 来验证我使用的密码是否正确。

对于 PFX 文件不使用密码的所有配置,安装都可以正常进行。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蘸点软妹酱 2024-11-10 08:12:24

在互联网上其他地方查看类似的问题,看起来返回代码 3 是“文件未找到”问题。您确定包含正确的 pfx 文件吗?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文