10

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?

1
  • 1
    FWIW, my issues were solved by running VS as admin -- but I have a known good .pfx file -- has your .pfx file worked anywhere? Was it generated by Visual Studio? (I generated mine via the command line a long time ago, but I remember, in order to get all the details in there to make Visual Studio happy, it took about 10 different commands, and about 3 different toolkits... and in the end I ended up with both a .cer and a .pfx file...) May 16, 2013 at 22:01

2 Answers 2

2

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.

1
  • I don't see any "OK" option in Visual Studio Community 2019 Dec 1, 2021 at 20:32
0

Select the startup project in the Solution Explorer Then click Project --> Properties in order to open a tab with all the config. Select the Signing tab in the left Click "Create Test Certificate" and enter a password. After doing this, there should be a new option in the "Choose a strong name file" dropdown. Choose this option, save, and build the project

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.