【发布时间】:2019-01-03 11:30:01
【问题描述】:
我们将使用 AWS CloudHSM 服务来保证所有代码签名证书的安全,并在我们的构建服务器上执行代码签名。我们的构建服务器是 Windows Server 2010,所以我在那里安装了 AWS CloudHSM 客户端。我激活了集群,所有命令行工具都按预期工作:我能够登录、添加密钥、查找密钥等。我们想继续使用 signtool 来签署我们的二进制文件,所以我认为我们可以使用密钥存储提供程序 (KSP)适用于 AWS CloudHSM,与其他工具一起安装。
Cavium KSP 和 CNG 提供程序已成功安装,并且在 Windows 加密提供程序的列表中可见。我在这里定义了环境变量(https://docs.aws.amazon.com/cloudhsm/latest/userguide/ksp-library-prereq.html)。
我通过 certutil 将证书添加到 HSM 存储:
Certutil -CSP "Cavium Key Storage Provider" -user -importPFX "certificate.pfx"
SDK Version: 2.03
Enter PFX password:
Certificate "myCertificate" added to store.
CertUtil: -importPFX command completed successfully.
证书已成功添加,当我从 key_mgmt_util.exe 控制台执行 findKey 命令时出现。
之后,我尝试使用 https://docs.microsoft.com/en-us/windows-hardware/test/hlk/user/hlk-signing-with-an-hsm 中所述的证书签署二进制文件:
signtool_64 sign /n myCertificate "test.exe"
或
signtool sign /sha1 4F555EF9FAB8E86A2F84ACF325362A29FB64AF66 "test.exe"
但我遇到了一个我无法解决的错误
SDK Version: 2.03
Done Adding Additional Store
SignTool Error: An error occurred while attempting to load the signing
certificate from: C:\temp\test.exe
我还尝试指定密钥存储提供程序和密钥容器
signtool sign /csp "Cavium Key Storage Provider" /k CARoot-877f51a1-90ee-4c10-8feb-02925caab4fb test.exe
返回给我
SignTool Error: An unexpected internal error has occurred.
Error information: "Could not associate private key with certificate." (-2147024
891/0x80070005)
和
signtool sign /f certificate.pem /csp "Cavium Key Storage Provider"
/k CARoot-877f51a1-90ee-4c10-8feb-02925caab4fb test.exe
其他错误信息
SignTool Error: The specified private key does not match the public key of the selected certificate.
在我看来,存储中的证书有问题,但我不知道如何解决这个问题。 test.exe 存在于磁盘上,可以使用来自其他提供商的证书或在指定 pfx 文件时使用 signtool 进行签名。
我做错了什么? Amazon CloudHSM 客户端是否与 signtool 兼容,或者我如何在 Windows 上使用 Amazon CloudHSM 作为密钥存储来签署二进制文件?
【问题讨论】:
-
嗨@toohtik,你在这方面有什么进展吗?我也想使用 Cloud HSM 提供商来签署二进制文件,但我没有看到任何报告表明它确实有效。
-
嗨@DaveJ 看看我的答案,谢谢
-
感谢@toohtik 花时间更新。如果有的话,您能否发布进一步的更新。再次感谢,非常感谢。
标签: amazon-web-services certificate code-signing hsm signtool