zoukankan      html  css  js  c++  java
  • [.NET]

    依据文档:

    https://msdn.microsoft.com/en-us/library/hh415055(v=vs.110).aspx

    虽然文档上给出了看似完整的步骤,但是如果按照上面的步骤,结果是失败的。而且文档的里的option还用错了。(-ac应该用-a, -ac是用于keypaircontainer)

    以下是一个完整的强签名迁移的sample:

    用于测试的代码,可以建一个console app,类似下面的例子:

    using System;
    
    using System.Reflection;
    
     
    
    namespace CLR6
    
    {
    
        class Program
    
        {
    
            static void Main(string[] args)
    
            {
    
                Console.ReadLine("Hello world!");
    
            }
    
        }
    
    }

    按照Signing with SHA-2, with Key Migration的1~3步骤,生成

    IdentityKey.snk,SignatureKey.snk,IdentityPubKey ,sha256的SignaturePubKey.snk。

    然后用第四步的命令来获取AssemblySignatureKeyAttribute需要的两个参数,注意用-a而不是-ac:

    sn -a IdentityPubKey.snk IdentityKey.snk SignaturePubKey.snk

    生成的两个参数需要从控制台窗口拷贝到本地,可以存到text文件。

    在需要重签名的程序文件添加assembly标签,通常是把它放在AssemblyInfo.cs文件中:

    using System;
    
    using System.Reflection;
    
     
    
    [assembly: AssemblySignatureKeyAttribute("002400000c800000940000000602000000240000525341310004000001000100e3997384795973ec459c8ec80019bce59a2edb42dd069cc4f25037370f41e0d041eff3995d26ed28fa0610105ffee4c61992b64a79bfb3af07321eeea3c3c8b9b149efdd5c3ac2962e7ce0d416c5bb1637d438aeb09648f40db8d3d04081f554adf8ea1295b1344bfdde7ec48cae46bdd68f58aa00f4e37a289e55972446b9bc",
    
    "8f29590c4f363e4c468f12c324f5d8ce76887a6bb246dd3237204a8f3232d1284c5a3a74405f235715527b7bd4ff73cd17ee242b863a335cb55c368f6ae8f769d6374fa9daa850d9aed6f19c989b44ffd56a0d8088629962d0e66bf942b3d21a11f54ef5f2800b404a4cc63dcf6380186366caea7c2a8ce25a433767ea2f828e")]
    
     
    
    namespace CLR6
    
    {
    
        class Program
    
        {
    
            static void Main(string[] args)
    
            {
    
            }
    
        }
    
    }

    然后运行延迟签名和fully sign命令。这样一个加强了的强命名程序集产生了,用ildasm看元数据的话, 很清楚的能看到AssemblySignatureKeyAttribute被编译器插入到程序集中了。

  • 相关阅读:
    linux 短信收发
    sama5d3 环境检测 adc测试
    【Codeforces 723C】Polycarp at the Radio 贪心
    【Codeforces 723B】Text Document Analysis 模拟
    【USACO 2.2】Preface Numbering (找规律)
    【Codeforces 722C】Destroying Array (数据结构、set)
    【USACO 2.1】Hamming Codes
    【USACO 2.1】Healthy Holsteins
    【USACO 2.1】Sorting A Three-Valued Sequence
    【USACO 2.1】Ordered Fractions
  • 原文地址:https://www.cnblogs.com/fred-bao/p/4566887.html
Copyright © 2011-2022 走看看