强签名和更新引用程序集

发布于 2024-08-31 19:15:26 字数 400 浏览 1 评论 0原文

我有两个第三方程序集:

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 技术交流群。

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

发布评论

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

评论(3

凉栀 2024-09-07 19:15:26

您可以使用 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.

锦爱 2024-09-07 19:15:26

您可以使用 SN.exe 工具对程序集进行签名(使用 -R 开关对已签名的程序集进行签名)。

但您必须意识到修改第三方组件可能是非法的。因此,在这样做之前请确保不存在法律问题。

而且我不知道有任何工具可以自动更改引用。您可以在元数据表 #35 中找到它们,其结构如下:

  • MajorVersion、MinorVersion、
    内部版本号、修订号(2 字节
    常量)
  • 标志(4 字节位掩码类型
    AssemblyFlags)
  • PublicKeyOrToken(Blob 索引)
    堆 – 公钥或令牌
    识别此内容的作者
    程序集)
  • 名称(字符串堆的索引)
  • 区域性(字符串堆的索引)
  • HashValue(Blob 堆的索引)

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:

  • MajorVersion, MinorVersion,
    BuildNumber, RevisionNumber (2-byte
    constants)
  • Flags (a 4-byte bitmask of type
    AssemblyFlags)
  • PublicKeyOrToken (index into Blob
    heap – the public key or token that
    identifies the author of this
    Assembly)
  • Name (index into String heap)
  • Culture (index into String heap)
  • HashValue (index into Blob heap)
吹梦到西洲 2024-09-07 19:15:26

我发现这篇文章准确地演示了如何做到这一点。

它涉及使用 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

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