【问题标题】:How do I securely store a .pfx password to use in MSBuild?如何安全地存储 .pfx 密码以在 MSBuild 中使用?
【发布时间】:2013-07-17 21:15:12
【问题描述】:

我需要将证书签名添加到我的构建中。下面是我编写的工作脚本示例,但它包含 .pfx 文件的密码。我无法在构建脚本中保留密码。在这种情况下,您会使用哪些“最佳做法”或技巧?

<ItemGroup Label="SignFiles">
  <SignFilesInclude="$(FileLocation)\**\*.exe"/>
</ItemGroup>

<Exec Command="$(SignTool) sign /v /ac C:\MSCV-VSClass3.cer /f C:\Certificate.pfx /p Password /t http://timestamp.verisign.com/scripts/timestamp.dll %(SignFiles.Identity)"/>

谷歌搜索后,我在多个地方读到,一旦您第一次使用密码运行脚本,.pfx 就会存储在证书存储中,之后构建脚本中将不需要密码。这行得通,但是我想确保这是最好的方法,或者更好的是,有一种方法可以避免将密码放入脚本中。

【问题讨论】:

    标签: msbuild code-signing password-protection pfx signtool


    【解决方案1】:

    将您的 .pfx 文件导入到 Windows 证书管理器中,以获取构建时使用的用户帐户。然后使用signtool/sha1开关选择正确的证书,不需要密码。

    1. 以构建用户身份登录
    2. 运行certmgr.msc
    3. 右键单击证书 - 当前用户 / 个人 / 证书,然后选择所有任务 / 导入...
    4. 选择您的 .pfx 文件,输入密码,然后单击下一步完成
    5. 双击导入的证书
    6. 详细信息页面中,指纹算法应该是sha1
    7. 复制指纹,它看起来像12 34 56 78 90 ab cd ef 12 34 56 78 90 ab cd ef 12 34 56 78
    8. signtool /sha1 1234567890abcdef1234567890abcdef12345678 /t http://timestamp.verisign.com/scripts/timestamp.dll %(SignFiles.Identity)

    并且第 8 步不会要求输入密码。

    【讨论】:

    • 我相信signtool 命令行示例错过了sign 命令。应该是signtool sign /sha ... /t ... file
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-13
    • 2016-04-01
    • 2010-11-28
    • 1970-01-01
    相关资源
    最近更新 更多