SignTool.exe 偶尔会失败,退出代码为 1

发布于 2025-01-07 12:21:20 字数 366 浏览 9 评论 0原文

作为构建系统的一部分,我们使用带有证书的 Signtool.exe 在构建二进制文件后对其进行签名。有时(很难说它何时会发生),签名会失败:

 error MSB3073: The command "C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin\signtool.exe" [...] exited with code 1.

根据 MSDN,退出代码 1 意味着对文件进行签名时出错。我可以验证该文件没有被签名。

我还注意到,有时时间戳部分会超时并显示不同的错误消息,尽管文件仍然经过签名(没有时间戳)。

如何排除和修复这些看似随机、不一致的签名失败?

As part of our build system, we use signtool.exe with a certificate to sign our binaries once they've been built. Occasionally (it's hard to tell when it will strike), the signing fails:

 error MSB3073: The command "C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin\signtool.exe" [...] exited with code 1.

According to the MSDN, an exit code of 1 means that there was an error signing the file. I can verify that the file didn't get signed.

I've also noticed that occasionally, the timestamp portion times out with a different error message, albeit that the file still gets signed (without the timestamp).

How can I troubleshoot and fix these seemingly random, inconsistent signature failures?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

最笨的告白 2025-01-14 12:21:20

我强烈怀疑与时间戳服务器的连接失败是造成偶尔失败的原因。也许您检查系统事件日志是否有在相关时间丢失的连接。

I strongly suspect a failing connection to the timestamp server being responsible for occasional failures. Perhaps you check your system event log for lost connections at the time in question.

甜柠檬 2025-01-14 12:21:20

我也有同样的问题。发生这种情况是因为 MS 反恶意软件进程 MsMpEng.exe 检查二进制文件并且不允许任何人访问它。
为了解决这个问题,我在 RAM 磁盘上构建了二进制文件,它成功了。

I had the same problem. It happens because MS antimalware process MsMpEng.exe check the binary and don't let anyone access it.
To solve the problem, I build binary on RAM disk and it worked.

白况 2025-01-14 12:21:20

我刚刚在 Windows 8.1 上遇到这个问题,所以这不是一些人引用的 Windows XP 根证书问题。

我发现问题是因为正在签名的.exe也在运行而引起的。

如果您从 cmd 提示符运行 signtool 并尝试对其进行签名,您将收到一条有用的文本消息,告诉您出了什么问题(比 CreateProcess() 的返回码 1 好得多。

停止正在运行的进程并能够正常签名。

I've just into this issue, on Windows 8.1, so it's not the Windows XP root certificates issue that some folks cite.

I found that the problem was caused because the .exe being signed was also running.

If you run signtool from the cmd prompt and try to sign it you will get a helpful text message telling you what is wrong (so much better than the return code 1 from CreateProcess().

Stopped the running process and was able to sign OK.

街角卖回忆 2025-01-14 12:21:20

就我而言,解决方案中的 .pfx 文件是旧文件。直到有人告诉我将证书文件替换为新的有效证书文件,我才继续收到“失败并退出代码 1”错误。

意思是,确保证书文件有效且未过期。

In my case, the .pfx file in the solution was an old one. Until someone told me to replace the certificate file with the new, valid one, I continued to get "Fails with Exit Code 1" error.

Meaning, make sure that the certificate file is valid and not expired.

烟酉 2025-01-14 12:21:20

SignTool.exe 有一个 /v 开关(详细),可以帮助您诊断问题。

SignTool.exe has a /v switch (verbose) which can help you diagnose the problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文