Subscribers can be a digital signature with a private key. The result is called a strong named assembly .
When a strong named assembly is loaded, .NET automatically checks to see if its signature matches the built-in public key. Therefore, when a strong named assembly is loaded, you have a guarantee that the author has a private key that matches this public key.
You can get the public key by calling Assembly . GetName () . GetPublicKey () , and then compare it with the expected one, i.e. your.
You can scan through plugin assemblies, create an AssemblyCatalog for each of them with the correct public key (reject the rest), finally merge them into AggregateCatalog and build a CompositionContainer with it.
This is basically what Glenn Block also explained in this thread . (It’s best to ignore the Bnaya blog post; its interpretation of StrongNameIdentityPermission is incorrect.)
edit with answers to the comment wall:
To get this public key, I do a console application that displays the publication of a key byte array. I insert an array of bytes in my host application, and subsequently use this for comparison against the public keys of the candidates plugin. Would this be a way to do this?
Yes, but there is an easier way to extract the public key. Take a look at the -Tp sn.exe parameter.
Does this mechanism automatically prevent the build of the malicious plugin from opening the correct, but "fake" public key? As in the case, is there any mechanism to disqualify any assembly that is signed, but has a mismatch between the public key and the public private key, from loading / running in general?
As far as I know, verification happens automatically. A strong named assembly cannot be loaded (even dynamically) if its signature is incorrect. Otherwise, a strong name would be useless. To test this, you can open your strong named assembly in a hex editor, change something (for example, a character in the const string built into the assembly) and make sure that the assembly is no longer loading.
I guess I meant something similar to the hack / crack type described here: http://www.dotnetmonster.com/Uwe/Forum.aspx/dotnet-security/407/Signed-assemblies-easily- cracked here too: http://blogs.msdn.com/b/shawnfa/archive/2008/05/14/strong-name-bypass.aspx
[... scan more comments ...]
However, this can apparently be bypassed by a simple fake (as shown in the first link, and explained more here): grimes.demon.co.uk/workshops/fusionWSCrackOne.htm
The “attacks” that you call fall into three categories:
- removes a strong name at all. This does not violate authentication, the assembly will no longer have a public key, so you will reject it.
- disable strong name verification, which requires full access to the machine. If this was done by an attacker, it means that the attacker already owns your machine. Any such security mechanism in this context does not make sense. In fact, we protect the attacker between the machine and the source of assemblies.
- real exploit caused by a bug in .NET 1.1 that has since been fixed
Conclusion: strong names are suitable for use for authentication (at least with .NET 2.0)