Strong naming with PFX

Chris picture Chris · Nov 21, 2011 · Viewed 8.5k times · Source

I'm trying to strong name an assembly with a PFX file that is also used for digitally signing. The PFX certificate has the CodeSigning option and was provided by a CA.

When I try to use it I get the following error:

error MSB3325: Cannot import the following key file: myCert.pfx. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name: VS_KEY_B763CB2413AC1708

I've tried to delete it and reinstall the PFX using

sn -d VS_KEY_B763CB2413AC1708
sn -i myCert.pfx VS_KEY_B763CB2413AC1708

But that did not work. I've tried to put the certificate in the certificate store - that also did not change a thing. I've tried to run Visual Studio as an administrator as well as executing MSBuild from the command line.

I've also tried to delay sign the assembly with a locally generated certificate (that worked) and then resign it using

sn -R myAssembly.dll myCert.pfx

Then I get the following error:

Failed to re-sign the assembly -- Keyset does not exist

I found the requirements for the code signing certificate in ClickOnce Manifest Signing and Strong-Name Assembly Signing Using Visual Studio Project Designer's Signing Page, Signing Assemblies. It looks like they're all met, but I'm probably missing something. How can I tackle this problem?

Answer

Akxaya picture Akxaya · Oct 31, 2012

I hope this will help with a quick solution. Go to

Visual Studio project properties -> Signing -> Sign in assembly -> Choose a strong name file -> (drop down) select Browse.. -> select <your>.pfx file -> OK**

Voila, you are all set to execute your project.