How the CLR verifies that my application is using the correct build

I know this is done by signing the private key assembly.

So, here is how I see the process ... When we have a private / public key pair file, we can compile it using these keys. So, what has been done is that the compiler opens the file "sk" (or pfx) and returns the private key (which I understand is impossible for a person), and after signing the assembly with the private key, it adds the public key to the assembly manifest and this is I have a strongly named assembly.

So when I launch an application that references this? What does the CLR mean to ensure that assebly is not replaced and nothing has changed?

+4
source share
2 answers

Quote from CLR via C #

Signing an assembly using a private key ensures that the owner of the corresponding public key assembly. When the assembly is installed in the GAC, the system hashes the contents of the file containing the manifest and comparing the hash value with the digital RSA signature value embedded in the PE file (after it has the public key). If the values ​​are identical, the contents of the files havent been tampered with, and you know that you have a public key that matches the publishers of the private key. In addition, the hashes of the system the contents of the assemblies are different files and compares the hash values ​​with the hash values ​​stored in the manifest file FileDef. If the hash values ​​do not match, at least one of the assembly files has been tampered with and the assembly will not be installed in the GAC.

Well, here's how it works.

When you compile an assembly, noting that you want to sign it with a pair of public / private key files already created, the compiler calculates the hash of the assembly (also calculates the hashes for each file in the assembly and stores the values ​​along with the file names in the FileDef table), then it signs the hash -value using the private key and inserts the public key into the manifest for this assembly.

Now, when the application (assembly) tries to load the signed assembly, the assembly is hashed again, then the CLR obtains the public key from the assembly manifest and decrypts the RSA sign and compares the hash value with the sign value. If they match, nothing has changed.

+3
source

The strong name contains the fingerprint of the public key. In this way, the CLR can check if the puppet key matches the name, and if the assembly is signed with the corresponding private key.

Good article on strong title: http://ondotnet.com/pub/a/dotnet/2003/04/28/strongnaming.html

When you establish a link from one assembly to another, the calling assembly retains the public key representation of the called assembly. At run time, the CLR can use this to verify that the assembly reference comes from the correct provider.

0
source

All Articles