Authenticode的替代时间戳服务

Ste*_*lly 105 timestamp code-signing

我们为所有生产版本执行代码签名和时间戳.偶尔(通常在我们即将进行RTM(!)时)Verisign的时间戳服务器(" http://timestamp.verisign.com/scripts/timstamp.dll ")决定间歇性地脱机.

在这种情况下我们该怎么做?

  • 时间戳服务器是否必须由根证书颁发机构托管?
  • 如果他们的服务器关闭,我们可以使用任何其他网络托管的时间戳服务器而不是Verisign吗?欢迎提供其他高可用和免费替代品的建议:)

flo*_*dob 83

我使用以下批处理文件,最多循环300次.有两个参数,%1是包含批处理文件,pfx文件和signtool.exe的文件夹的路径.%2是要签名的文件的完整路径.您可以在visual studio post build事件中调用此方法,例如调用"$(SolutionDir)thirdparty\signing\sign.bat""$(SolutionDir)thirdparty\signing""$(TargetPath)"我已将此批处理文件修改为在每次迭代中使用不同的时间戳服务器.目前它使用Comodo,Verisign,GlobalSign和Starfield.希望这是终极签名脚本;)

@echo off    

REM create an array of timestamp servers...
set SERVERLIST=(http://timestamp.comodoca.com/authenticode http://timestamp.verisign.com/scripts/timestamp.dll http://timestamp.globalsign.com/scripts/timestamp.dll http://tsa.starfieldtech.com)

REM sign the file...
%1\signtool.exe sign /f %1\comodo.pfx /p videodigital %2

set timestampErrors=0

for /L %%a in (1,1,300) do (

    for %%s in %SERVERLIST% do (

        REM try to timestamp the file. This operation is unreliable and may need to be repeated...
        %1\signtool.exe timestamp /t %%s %2

        REM check the return value of the timestamping operation and retry a max of ten times...
        if ERRORLEVEL 0 if not ERRORLEVEL 1 GOTO succeeded

        echo Signing failed. Probably cannot find the timestamp server at %%s
        set /a timestampErrors+=1
    )

    REM wait 2 seconds...
    choice /N /T:2 /D:Y >NUL
)

REM return an error code...
echo sign.bat exit code is 1. There were %timestampErrors% timestamping errors.
exit /b 1

:succeeded
REM return a successful code...
echo sign.bat exit code is 0. There were %timestampErrors% timestamping errors.
exit /b 0
Run Code Online (Sandbox Code Playgroud)

我还将http://timestamp.comodoca.com放入可信站点(感谢Vince).我认为这可能是重要的一步.我也更新了PC上的根证书.

  • 我只是在这里掏钱.我知道这是一个陈旧的答案.但是这个剧本"几乎"完美,所以我想填补我的变化.当脚本作为构建后事件运行时.如果时间戳失败但后续时间戳成功,则构建仍然失败,因为MSBuild监视signtool.exe发生的事件并发现失败,因此认为它是失败的.我在VS2012和构建机器中发生过这种情况.我的修复是更改时间戳以将其抽象为另一个cmd,因此MSBuild无法进行间谍:启动/等待"签名工具"/ D"%1""signtool.exe"timestamp/t %% s%2 (2认同)
  • 如果您在 PostBuildEvent 中使用此脚本,并且第一次尝试失败但下一次成功,则构建会失败,因为 msbuild 试图变得过于聪明,并拦截写入控制台和错误控制台的信息并解释存在即使 ERRORLEVEL 为 0,也会出现错误。这里可以提出一种解决方案 /sf/answers/1338661621/ 是将标准输出和错误输出重定向到 nul,因此对signtool 的调用是 ```% 1\signtool.exe 时间戳 /t %%s %2 2>nul 1>nul``` (2认同)

gre*_*mac 15

我不确定时间戳服务器是否必须由根CA拥有.

我们使用http://timestamp.comodoca.com/authenticode(并且有一个Comodo authenticode证书),但实际上有一个类似的问题,因为他们的服务器似乎偶尔会给出错误或超时.我们在持续集成服务器上进行夜间(或按需)构建的一部分,仅用于发布版本(不适用于调试版本).

我(主要)以两种方式解决了这个问题:

  • 如果对signtool.exe的调用失败,它会再次(立即)再次尝试两次
  • 构建脚本用于一步签署每个exe(我们有几个作为我们产品的一部分),现在它一个接一个 - 需要稍长,但不太可能失败

在这些之间,由时间戳服务器问题引起的构建失败已经从一周一次或两次变为几乎从不.

编辑:我有一个MSBuild任务执行此操作(以及读取存储库外存储的证书密码),地址是https://gist.github.com/gregmac/4cfacea5aaf702365724


Dav*_*vid 12

它通过以下其中一个替换verisign时间戳url很好地工作:

http://timestamp.comodoca.com/authenticode
http://www.trustcenter.de/codesigning/timestamp

  • 似乎时间戳不再来自trustcenter.de:"赛门铁克所有产品和服务由TC TrustCenter GmbH提供已不再可用.如有任何疑问,请联系:Symantec TC TrustCenter 24/7电话支持电话:+1 -800-579-2848或+ 1-520-477-3104" (2认同)

Ric*_*Web 11

您通常可以使用任何您想要的时间戳服务。尽管大多数 CA 将提供时间戳服务。例子

http://timestamp.globalsign.com/scripts/timstamp.dll
http://timestamp.comodoca.com/authenticode
http://www.startssl.com/timestamp
http://timestamp.digicert.com?alg=sha1
http://timestamp.digicert.com?alg=sha256
Run Code Online (Sandbox Code Playgroud)

timestamp.verisign.com 于 2019 年后端正式 EOL,有关更多信息,请参阅我对以下问题的回答。

http-timestamp-verisign-com-scripts-timstamp-dll-not-available


BCr*_*ran 7

可以使用任何时间戳服务器:我最近从发行者的时间戳服务器切换到Verisign,因为我发现GlobalSign的服务器不可靠.此外,Thawte不会运行他们自己的时间戳服务器,但建议人们使用Verisign.


dya*_*sta 6

VeriSign时间戳服务是免费的.这可能也许是为什么它的可靠性不够充分; 他们不给它一个维护预算!

绝对这是一个问题.由于代码时间戳失败构建失败而浪费的时间是整个软件开发行业日益严重的问题.当然,你可以写一个复杂的脚本来旋转,直到你找到一个工作时间标记服务器..但是,真的吗?

我们应该要求更好.我们为这些证书支付了很多钱.

请注意,我后来发现很少有人听说过的备用时间戳服务器可以在Verisign和Comodo停机期间使用(通常在工作日的工作时间内发生).