Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to sign a .NET Assembly DLL file with a Strong Name? [duplicate]

I have an assembly which is not strong-named. I have no source code for it.

I now need it to be signed. Is there a way to do this?

like image 489
guaike Avatar asked Aug 03 '09 03:08

guaike


People also ask

How do I sign a .NET DLL?

In VS cmd <your project path>sn -k <name of your project>. snk Then go to your project in Solution Explorer -> properties -> Signing -> check checkbox -> Browse to the key which is created using VS cmd.

How do I sign a DLL?

Once you obtain a certificate (cer) or Personal Information Exchange (pfx) file, you can sign your DLL(s) using signtool. Alternatively, you can also use an online Authenticode signing service, such as Symantec's Secure App Service - https://www.symantec.com/code-signing/secure-app-service/.


1 Answers

If the original assembly is marked for delayed signing, then you can use the sn.exe tool.

If the original assembly is not so marked, then you can disassemble it with ildasm.exe, then re-asssemble it with ilasm.exe and specify the /key argument. References: [1] [2].

Example:

> ildasm /all /out=MYASSEMBLY.il MYASSEMBLY.dll > ilasm /dll /key=key.snk MYASSEMBLY.il 
like image 107
Cheeso Avatar answered Sep 24 '22 12:09

Cheeso