Strong name assembly using installed certificate

313 Views Asked by At

Certmgr shows I have my company's Symantec Class 3 SHA256 Code Signing CA installed, along with ones with Private in the name. Can I add this line to my Assembly Info:

[assembly: AssemblyKeyName("what name do I use here?")]

to strongly-name an assembly at build time? Would that find the public/private key pair in the certificate store and insert them into my assembly? Or do I have to extract the public/private key pair from the certificates and use the well-documented process for strong-naming that I see all over the Internet?

I've tried the above with variations of the company name but build fails with:

Keyset does not exist

1

There are 1 best solutions below

0
Daniel Fisher  lennybacon On

Here is a blog post that explains what needs to be done: https://matthewdippel.blogspot.com/2017/09/howto-strong-name-sign-net-assembly.html

However, there’s an ugly catch-22. Running sn.exe -c, if it ends up changing the CSP, can only be done as an elevated user. However, that same elevated user cannot access the key in the personal store of your non-elevated account. So simply adding this to the pre-build or post-build and running Visual Studio under elevation results in the exact same Keyset not found error on build. ... To get this working, you’ll need the script located at this gist. The only requirement is that you have the .Net Framework SDK 4.6, 4.6.1 or 4.6.2 installed. It uses it to get the path to the sn.exe file so that it’ll work regardless of how your system is configured.