Pregunta

I am trying to create my own tool to sign my assemblies with StrongNames using only C# code.

I have been able to generate the signature and keys using .Net RSA Classes in System.Security.Cryptography. My problem at this stage is to add the signature and public key to the assembly manifest.

Is this at all possible using code and not by making use of some tool ? Please note that I want to sign my assemblies outside of Visual Studio (at runtime) using only the .Net Cryptography classes to generate the key pairs.

I have tried to add the information using methods of the AssemblyName class in System.Reflection but I cannot commit the changes (It has a SetPublicKey Method).

Essentially what my application will do is similar to sn.exe, It is very important that I be able to add the signature and key to the manifest so that other strong named assemblies can reference mine.

If it comes to it, how can I read the private and public keys that are created by the sn.exe tool, I have tried but am unsure which encoding the .snk file uses ? If I cannot sign my assemblies using code, I will then use sn.exe, but for my own reasons I want to read the keys from the keypair file and use them with the RSA classes.

Any help will be greatly appreciated.

¿Fue útil?

Solución

The Mono project provide it's own sn tool which is entirely build in C# and depends on Mono.Security.dll (which works on Windows too). All of this is open source under the MIT license.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top