. NET Assembly delayed Signature

Source: Internet
Author: User

One advantage of a strongly-named assembly is tamper-proofing. Assume that I have an Assembly named MyDll. dll. If I use my own private key for signature and hash the content in the Assembly, if others do not know my private key, you cannot tamper with this Assembly to perform some malicious behavior.
However, for the development of some large programs, the private key is generally not public. Of course, the public key that matches it is public and can be freely distributed. So how to ensure that developers use a strongly-named assembly in the development process (for example, to put it in GAC, it must be a strongly-named assembly ). Delayed signature is for this purpose.
Take MyDll. dl as an example:
1) generate a public/private key pair
Sn-k Company. snk
2) extract the public key and keep the private key safe.
Sn-p Company. snk public. snk
3) Delayed signature of the Assembly
Csc/keyfile: public. snk/delaysign/t: library MyDll. cs
4) Let CLR trust the Assembly content without performing hash Processing
Sn-Vr MyDll. dll
Since the above name will add corresponding items in the registry, you only need to execute the same Assembly once.
In this way, MyDll. dll can be installed in GAC (if you want)
5) other developers can reference this Assembly, just like a strongly-named assembly.
6) if the development is complete and the final deployment is required, the private key must be used for signature.
Otherwise, someone can use this public key to make the same assembly to replace your assembly and do some bad things.
In short, the security of the Assembly will be greatly reduced. To this end, let the person who saves the private key complete the following signature
Sn-R MyDll. dll Company. snk
Note: we cannot extract the private key separately. The private key and public key are in a file. The public key can be extracted separately for distribution.
7) enable verification. The Registry Key in 4) will be removed accordingly.
Sn-Vu MyDll. dll

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.