问题 如何正确地使用时间戳的双重签名代码?


我有两个代码签名证书(一个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)上验证失败。

这种事情甚至可能吗?


1384
2017-12-16 00:11


起源

嗯,很高兴知道我并不孤单,因为我需要这个...... - vcsjones
你试过了吗 /td sha256 /tr ... 代替 /t ... 第二次签名? - Thomas Weller


答案:


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月),您应该将其更新为上面的。与Verisign一样,GeoTrust现在也是赛门铁克的一部分。

资源:

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


12
2017-12-07 03:37



感谢您解释“为什么它不起作用”,我读过的其他答案错过了那一部分。为了使其工作,只需更换 /t http://timestamp.verisign.com/scripts/timestamp.dll 同 /tr http://timestamp.geotrust.com/tsa。 - James L.
GeoTrust服务器仍然使用SHA1摘要作为时间戳,更糟糕的是,他们的证书链终止于带有MD5摘要的根证书。如果您想使用时间戳使用SHA256摘要 timestamp.globalsign.com/?signature=sha2 作为URL(指定/ td SHA256也不会伤害)。 - Igor Levicki
带有RFC 3161时间戳URL的SHA-256是 sha256timestamp.ws.symantec.com/sha256/timestamp - Jem Tucker