bwe*_*ber 5 windows code-signing certificate digital-signature
我的目标是使用证书在 Windows 上签署一个未签名的可执行文件。根据我的一般知识,我知道我需要一个公钥和一个私钥对来进行数字签名。我还安装了 Windows SDK,它提供signtool.exe和makecert.exe.
我已经在线获得了证书,包括 CER、PEM 和 CRT 文件。
我现在的问题是我必须如何使用这些工具和证书文件来签署可执行文件。根据这里,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>
Run Code Online (Sandbox Code Playgroud)
这里<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.
Run Code Online (Sandbox Code Playgroud)
对于它的价值,我为开源项目购买了 Certum Cloud Signing,这是我如何让它工作的。(我花了 5 个工作日的邮件、尝试和错误以及在波兰语文档上使用谷歌翻译,所以也许我可以为某人节省一点时间)
您首先提供您的个人信息,一旦您收到激活令牌,您只有 24 小时的时间来激活它。(即使未指定此信息,也不要像我一样让时间流逝),因此:
使用如下链接中的“重新获得对 SimplySign 服务的访问权限的秘密”:https ://cloudsign.webnotarius.pl/arc/app/resetseed?token = ...
在那里你会得到一个你应该在SimplySign 移动应用程序上使用的新代码(我相信是重置按钮)。
我无法在 google play 上找到 SimplySign 移动应用程序。因此,我使用桌面浏览器找到了该应用程序(上面写着“此应用程序与您的设备不兼容”和/或国家/地区...)并使用 chrome 扩展程序下载了 APK,然后在我的手机上手动安装。
设置好移动应用程序后,它应该每分钟左右生成 6 位数字令牌。
现在在 Windows 上安装 SimplySign 桌面。使用您的电子邮件和手机上的 6 位令牌登录。一旦它显示“状态:已连接”,它就安装了一个虚拟智能卡和您的证书。SimplySign 必须保持连接才能使证书生效。
signtool.exe sign /n "Open Source Developer, Your Name" /fd SHA256 YourApp.exe
Run Code Online (Sandbox Code Playgroud)
如果您不使用,/fd SHA256您将获得:
SignTool Error: SignedCode::Sign returned error: 0x80090027
The parameter is incorrect.
SignTool Error: An error occurred while attempting to sign: YourApp.exe
Run Code Online (Sandbox Code Playgroud)
如果您不登录 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.
Run Code Online (Sandbox Code Playgroud)
注意:无需安装proCertum SmartSign应用程序。
这解决了我的问题: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>
Run Code Online (Sandbox Code Playgroud)
这里<Issued_To>匹配证书中的值,<Filename>是要签名的文件的名称。然后对可执行文件进行签名。