Windows:如何使用Certum颁发的证书对exe进行签名?

问题描述 投票:1回答:2

我的目标是使用证书在Windows上签署未签名的可执行文件。根据我的一般知识,我知道我需要一个用于数字签名的公共密钥和私有密钥对。我还安装了Windows SDK,其中提供了signtool.exemakecert.exe

我已经在线获得了证书,包括CER,PEM和CRT文件。

我的问题是,我必须如何使用这些工具和证书文件来签署可执行文件。根据here,CRT文件是私钥。根据到目前为止的了解,CER和PEM文件基本相同,但编码不同。他们是干什么的?他们是公钥吗?以及如何签名可执行文件?

编辑:我尝试将CRT文件安装到证书存储,然后使用该证书签名:

"C:\Program Files (x86)\Windows Kits\8.1\bin\x64\signtool.exe" sign /debug /fd SHA256 /a /n "<Issued_To>" /t http://timestamp.comodoca.com/authenticode <Filename>

这里<Issued_To>被替换为证书中的数据,<Filename>是我要签名的文件的名称。我从signtool获得的输出如下:

The following certificates were considered:
    ...

    Issued to: ...
    Issued by: Certum Code Signing CA SHA2
    Expires:   Thu Oct 12 14:37:04 2017
    SHA1 hash: BA081A67D3F2DDDC9268121DCBA04F43D6CD37FB

    ...

After EKU filter, 1 certs were left.
After expiry filter, 1 certs were left.
After Subject Name filter, 1 certs were left.
After Private Key filter, 0 certs were left.
SignTool Error: No certificates were found that met all the given criteria.
windows certificate digital-signature code-signing
2个回答
2
投票

这解决了我的问题:http://www.anse.de/programming/code-signing-for-open-source-executable

我使用Firefox将证书导出为PK2文件。然后,我将此证书安装在Windows上的“个人”证书存储中。之后,我可以使用上述命令对可执行文件进行签名:

signtool sign /fd SHA256 /a /n "<Issued_To>" /t http://timestamp.comodoca.com/authenticode <Filename>

这里<Issued_To>与证书中的值匹配,<Filename>是要签名的文件的名称。之后,可执行文件被签名。


0
投票

出于其价值,我购买了Certum Cloud Signing用于开源项目,这就是我如何使它工作的方式。 (这花了我5个工作日的邮件时间,尝试和错误以及使用Google翻译波兰文档,所以也许我可以节省一些时间给某人)

您首先提供您的个人信息,收到激活令牌后,您只有24小时的时间来激活它。 (即使未指定此信息,也不要像我一样让时间过去),所以:

在看起来像这样的链接中使用“秘密重新获得对SimplySign服务的访问”:https://cloudsign.webnotarius.pl/arc/app/resetseed?token= ...

[您将获得一个应在SimplySign移动应用程序上使用的新代码(我相信,重置按钮)。

我无法在Google Play上找到SimplySign移动应用。因此,我使用桌面浏览器找到了该应用程序(显示“此应用程序与您的设备不兼容”和/或国家/地区...),然后使用chrome扩展程序下载了APK,然后在手机上手动安装。

一旦安装了移动应用程序,它应该每分钟左右生成6位数的令牌。

现在在Windows上安装SimplySign Desktop。使用您的电子邮件和手机上的6位数令牌登录。当它说“状态:已连接”时,它已经安装了虚拟智能卡和您的证书。 SimplySign必须保持连接状态,才能使用证书。

signtool.exe sign /n "Open Source Developer, Your Name" /fd SHA256 YourApp.exe

如果不使用/fd SHA256,您将得到:

SignTool Error: SignedCode::Sign returned error: 0x80090027
        The parameter is incorrect.
SignTool Error: An error occurred while attempting to sign: YourApp.exe 

如果您未登录SimplySign,则会得到:

After EKU filter, 1 certs were left.
After expiry filter, 1 certs were left.
After Subject Name filter, 1 certs were left.
After Private Key filter, 0 certs were left.
SignTool Error: No certificates were found that met all the given criteria.

注意:无需安装proCertum SmartSign应用程序。

© www.soinside.com 2019 - 2024. All rights reserved.