9

i'm applying a digital signature to my executable. Using signtool on Windows XP or Windows Vista:

>signtool.exe sign /f "avatar.pfx" MyApp.exe

automatically included the entire certification chain in the digital signature.

Starting with Windows 7 the entire certification chain is no longer included. You must manually include the certificate that:

  • signed your key
  • signed the certificate that signed your key
  • ...
  • ...until there are no more certificates to include

i am told that i have to do this using the /ac switch with the signtool utility.

From MSDN documentation of signtool:

/ac FileName
Specifies a file that contains an additional certificate to add to the signature block.

How do i get the filename of the certificate that signed my certificate?

It's more confusing because i don't have any such file. i have my digitally signed executable with no embedded certification chain:

enter image description here


Stackoverflow user davidcl had the same question. In this self-answered answer he says that i need to

do the signing using a PFX file that contains the root certificate, intermediate certificate, developer certificate, and private key.
After creating the appropriate PFX file - which was an odyssey in itself...

But he doesn't give how he created the PFX that contains the entire certification chain.


See also

4

2 回答 2

7

为 Windows安装OpenSSL。完成后,您将openssl.exe在系统的某个位置拥有可执行文件。

现在进行如下操作。

  1. openssl pkcs12 -in avatar.pfx -out avatar.pem -nodes

(您需要在此处输入 .pfx 密码)

  1. openssl pkcs12 -in avatar.pfx -out mycert.pem -nodes -clcerts

(又是私服)

  1. openssl x509 -in mycert.pem -out mycert.cer -outform DER

现在打开您的资源管理器并双击 mycert.cer。查看详细信息以及它将谈论发行人的地方。这是颁发您的密钥库的公司,您的下一个目标是获得他们的中间证书和最终的根证书。如果幸运的话,您的证书中有一个名为“Authority Information Access”的扩展程序,它会告诉您从何处直接获取颁发证书。如果你不是那么幸运,那么你会在“授权信息访问”中找到一个用于 OCSP 访问的 URL,或者在扩展“CRL 分发点”中找到一个用于 CRL 的 URL。这些至少应该让您对供应商的“主页”有一个模糊的概念。如有疑问,只需谷歌搜索,或再次询问我 :)

如果您在供应商的页面上,则必须注意“CA 证书”或“中间证书”。您需要下载与您在自己证书的“颁发者”字段中找到的名称完全相同的那个。

现在有趣的部分是:您刚刚找到的证书将再次具有“颁发者”字段。如果发行者是同一家公司(通常是 VeriSign 等大型 CA 的情况),那么您会很幸运,那么您将在您当前所在的同一站点上找到相应的证书。如果没有,请重复前面的步骤。

重复这个繁琐的过程,直到您找到一个“主题”字段与其“颁发者”字段完全相同的证书。那你就完成了。这就是所谓的“自签名根证书”。

大多数这些证书将采用“DER”/“ASN.1”/“X.509”格式 - 如果您有选择,请下载“PEM”格式,否则您首先需要将证书转换为“PEM”格式经过

openssl x509 -in cert.der -inform DER -out cert.pem

一旦您拥有 PEM 格式的所有缺失证书

  1. 在文本编辑器中打开在步骤 1 中创建的初始文件 avatar.pem。

  2. 在单独的窗口中打开丢失的证书 PEM 文件

  3. 复制丢失的证书(整个文件,包括“----- BEGIN CERTIFICATE -----”和“----- END CERTIFICATE -----”)并将它们附加到 avatar.pem

  4. 保存结果

  5. 问题

openssl pkcs12 -export -in avatar.pem -out newavatar.pfx -name ""

您将必须输入一个新密码,该密码将与新文件一起使用。

于 2011-07-11T18:55:58.420 回答
1

对 Ian 上面的评论“最后我有一个更简单的方法来获得 .cer ...”的评论。现在,当您从 Thawte 网页导出代码签名 pfx 时,您可以指定要包含整个链。因此,您可以使用 certmgr.msc 导入 pfx,然后将单个 Thawte 中间证书导出为 codesign.cer 文件。然后将其与 signtool /ac 开关一起使用。无需拥有旧的签名应用程序。请务必在商店中删除您的临时证书,以便您对新签名应用程序的测试有效。——威廉·克罗夫特

于 2013-07-12T01:32:22.010 回答