强签名和更新引用程序集
我有两个第三方程序集:
Foo.dll
和
ReferencesFoo.dll
如前所述,ReferencesFoo.dll
是一个引用了Foo.dll
对于我的应用程序,我需要放弃这些程序集。我将 ildasm/ilasm 与签名密钥结合使用来对它们进行签名,但是,ReferencesFoo.dll
仍然包含(在它的清单中?)对 Foo.dll
的引用旧公钥和公钥令牌。
那么,如何使用我的密钥对两个 dll 进行签名,并更新 ReferencesFoo.dll
中的引用,而无需获取源代码并重新编译?
I have two, third party assemblies:
Foo.dll
and
ReferencesFoo.dll
As noted, ReferencesFoo.dll
is an assembly that has a reference to Foo.dll
For my application, I need to resign these assemblies. I use ildasm/ilasm in combination along with a signing key to resign them, however, ReferencesFoo.dll
still contains (in it's manifest?) the reference to the Foo.dll
old public key and public key token.
So, how do I sign both dll's with my key, and update the references in ReferencesFoo.dll
without getting the source code and recompiling?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 Mono.Cecil 轻松做到这一点。打开 Foo.dll,用新的 snk 保存它,并更新其引用ReferenceFoo.dll 到适当的公钥令牌。
You can easily do that with Mono.Cecil. Open Foo.dll, and save it with your new snk, and update its reference in ReferenceFoo.dll to the appropriate public key token.
您可以使用 SN.exe 工具对程序集进行签名(使用 -R 开关对已签名的程序集进行签名)。
但您必须意识到修改第三方组件可能是非法的。因此,在这样做之前请确保不存在法律问题。
而且我不知道有任何工具可以自动更改引用。您可以在元数据表 #35 中找到它们,其结构如下:
内部版本号、修订号(2 字节
常量)
AssemblyFlags)
堆 – 公钥或令牌
识别此内容的作者
程序集)
You can sign an assembly with the SN.exe tool (using the -R switch to resign an already signed assembly).
But you have to be aware that modifying a third party component might likely be illegal. So make sure there are no legal problems before doing so.
And I'm not aware of any tools to automatically change references. You can find them in the metadatatable #35 which is structured as follows:
BuildNumber, RevisionNumber (2-byte
constants)
AssemblyFlags)
heap – the public key or token that
identifies the author of this
Assembly)
我发现这篇文章准确地演示了如何做到这一点。
它涉及使用 sn、ildasm、ilasm 和文本编辑器。
http://buffered.io/posts/net -fu-signing-an-unsigned- assembly-without-delay-signing
I found this article which demonstrates exactly how to do this.
It involved using sn,ildasm,ilasm, and a text editor.
http://buffered.io/posts/net-fu-signing-an-unsigned-assembly-without-delay-signing