如何使用时间戳正确地进行代码双重签名?

12

我有两个代码签名证书(一个SHA-1,一个SHA-256),我想将它们应用于同一个文件。我尝试添加SHA-256证书,但这样做失败了:

:: Signs with the SHA-1 certificate
signtool sign /sha1 8f52fa9db30525dfabb35b08bd1966693a30eccf /t http://timestamp.verisign.com/scripts/timestamp.dll my_app_here.exe
:: Signs with the SHA-2 certificate
signtool sign /sha1 8b0026ecbe5bf245993b26e164f02e1313579e47 /as /t http://timestamp.verisign.com/scripts/timestamp.dll my_app_here.exe

这会导致错误:

Done Adding Additional Store
SignTool Error: SignedCode::Sign returned error: 0x80070057
        The parameter is incorrect.
SignTool Error: An error occurred while attempting to sign: my_app_here.exe

如果我从第二个命令中删除时间戳URL,签名将成功完成,但SHA-2签名将没有时间戳。(无论是否在第一个签名上打时间戳都没有影响)
这里的意图是允许某人在支持此类功能的操作系统上使用更强的证书验证应用程序,但要避免在不支持更强证书(Vista、XP)的操作系统上失败验证。
这种事情可能吗?

很高兴知道我不是唯一需要这个的人... - vcsjones
你尝试过使用/td sha256 /tr ...而不是第二个签名的/t ...吗? - Thomas Weller
1个回答

12
SHA-2 Authenticode签名需要RFC 3161时间戳服务器。timestamp.verisign.com的URL无法使用。
Symantec / Verisign的RFC 3161 URL为:
http://sha256timestamp.ws.symantec.com/sha256/timestamp

如果你仍在使用较旧的http://timestamp.geotrust.com/tsa URL,并且它无法正常使用(2017年4月),那么你应该将其更新为上述URL。GeoTrust和Verisign一样,现在已成为Symantec的一部分。
来源:

https://knowledge.verisign.com/support/code-signing-support/index?page=content&id=SO5820


谢谢您解释“为什么它不起作用”,其他答案中我读到的遗漏了这一部分。要使其起作用,只需将/t http://timestamp.verisign.com/scripts/timestamp.dll替换为/tr http://timestamp.geotrust.com/tsa - James L.
1
GeoTrust服务器仍然使用SHA1摘要来生成时间戳,更糟糕的是,他们的证书链终止于一个具有MD5摘要的根证书。如果您想要SHA256摘要用于时间戳,请使用http://timestamp.globalsign.com/?signature=sha2 作为URL(指定/td SHA256也不会有任何影响)。 - Igor Levicki
4
SHA-256与RFC 3161时间戳的URL为http://sha256timestamp.ws.symantec.com/sha256/timestamp。 - Jem Tucker

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接