Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot import the following key file error when importing pfx

I researched this question thoroughly on stackoverflow and I have seen numerous answers but none of them have worked for us yet. We recently bought a code signing certificate from comodo that we are going to use to sign our c# WPF .net4 application.
We have followed the instructions on the following URL

and have then imported the certificate in visual studio under 'project properties->singing->sign the assembly'. We then try to build the project and get the following error:

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

We have found numerous solutions on the internet and have tried the following:

  • Click on Change Password and use the same password in all 3 places
  • sn -i [comodo].pfx VS_KEY_xxxxxxxxxxxxx
  • tried converting it to password-less snk file and use that instead of .pfx
  • Tried running visual studio as admin and importing key
  • Tried creating very simple barebones project and signing with that
  • Tried visual studio 2010 as well as 2012
  • We tried adding the following to the assembly [assembly: AssemblyKeyFile("path to key file")]
  • Added event in postbuild "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\signtool.exe" sign /f "$(ProjectDir)[keyfile].pfx" /p [thepassword] /v "$(ProjectDir)obj\Release\$(TargetFileName)"
  • Added in a section in the .csproj file:

  • Downloaded http://visualstudiogallery.msdn.microsoft.com/a83505c6-77b3-44a6-b53b-73d77cba84c8 and clicked 'Apply Fix' on the error

We have had no success thus far. We can import the key just fine using the password so we know the password is correct. We also know that this works fine for signing the manifest in a clickonce publish. Just to make sure we weren't having any other issues, we turned off the cilckonce signing and are just trying to sign the assembly.

like image 329
hobeau Avatar asked Mar 08 '13 00:03

hobeau


People also ask

How do I add a PFX file to Visual Studio?

Sign using an existing key fileClick the Select from File button. The Select File dialog box appears. In the Select File dialog box, browse to the location of the key file (. pfx) that you want to use, and then click Open.

What is a PFX file?

The . pfx file, which is in a PKCS#12 format, contains the SSL certificate (public keys) and the corresponding private keys. Sometimes, you might have to import the certificate and private keys separately in an unencrypted plain text format to use it on another system.


1 Answers

You can simply open "Project > Property > Signing" and uncheck the "Sign the ClickOnce manifests" checkbox.

like image 129
regufo Avatar answered Sep 16 '22 11:09

regufo