我可以从 DLL 中删除数字签名吗?
我的安装程序在构建过程中使用代码签名证书构建“签名”DLL。
我注意到,如果我尝试连续构建两次,第二次构建就会失败,因为 DLL 已经签名,因此符号代码会被阻塞。 显然,我可以通过在构建中签署 DLL 的副本来解决此问题,但这个问题引起了我的兴趣:
是否可以“取消签名”DLL,如果不能,为什么不......?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
signtool 可用于Windows SDK,并且必须至少来自 Windows 8 SDK 套件(版本 6.2.9200.20789)才能支持
remove
命令。signtool is available in Windows SDK, and must be at least from Windows 8 SDK kit (version 6.2.9200.20789) to have the
remove
command supported.您可以使用 XDA 论坛帖子中的 delcert.exe。
You can use delcert.exe from the this XDA Forum post.
使用 ImageRemoveCertificate API。
您的标签中没有指定任何语言,但本文介绍了如何在 C# 中实现它。 使用 C# 从文件中删除数字签名
除此之外,如果您正在寻找一个简单的工具来为您完成这项工作,您可以使用 FileUnsigner。
It's fairly easy to remove the signature from a .dll file using the ImageRemoveCertificate API.
You don't have any language specified in your tags but this article shows how to implement it in C#. Remove digital signature from a file using C#
Other than that, if you are looking for a simple tool to do the work for you, you can use FileUnsigner.
另一种可能的选择是切换到 SignTool。 exe。 它附带 Windows SDK 并对已签名的二进制文件进行签名不产生错误。 我在构建过程中使用了signtool.exe,即使某些内容已经签名,也没有任何困难。
另外,请查看问题 signcode 之间的主要区别是什么.exe 和signtool.exe?
Another possible option is to switch to the SignTool.exe. It comes with the Windows SDK and signing a binary that has already been signed does not generate an error. I use signtool.exe in my build process and haven't any difficulties with it, even when something is already signed.
Also, check out the question What's the main difference between signcode.exe and signtool.exe?
当然这是可能的,但并非微不足道。
尽管保存预签名 DLL 的副本会更容易。
此数字签名只不过是附加到 PE 文件末尾的额外部分。 如果需要,您可以编写一个删除签名的程序。
这并不像截断文件那么简单; 您必须删除对文件头中签名的引用。 如果 DLL 有多个签名而您只想删除一个签名,那么情况可能会变得复杂。
PE 文件的格式在此处公开记录
Sure it's possible, but not trivial.
Although it would be easier to save a copy of the presigned DLL.
This digital signature is little more than an extra section appended to the end of a PE file. You could write a program that deleted the signature, if you want.
It's not quite as simple as truncating the file; you have to remove references to the signature in the file header. It could get complicated if the DLL has multiple signatures and you just want to remove one.
The format of a PE file is publicly documented here
检查您的构建工具是否支持“重新签名”。 这应该替换所有现有的签名。
如果没有,您可以使用 Stud_PE 删除签名块。
在 Stud_PE 中打开 DLL 或 EXE,转到“部分”选项卡,右键单击数字签名部分并选择“删除部分”。 然而,这需要用户交互。 该工具的旧版本可能会破坏该文件。
Check if your build tool supports "Re-signing". This should replace all existing signatures.
If not, you can use Stud_PE to remove the signature block.
Open the DLL or EXE in Stud_PE, go to the sections tab, right click the digital signature section and select "Delete section". However, this needs user interaction. Old versions of the tool could destroy the file.