Monday 12 May 2014

Cannot import the keyfile myfile.pfx - error 'The keyfile may be password protected'

I've been doing some work to use Jenkins for CI and last week when we added our first plug-in (MS Dynamics CRM) to the project, the build broke.

Plug-ins are libraries that need to be strongly signed so I had added a password protected signing key, which is just a PKCS#12 certificate, myfile.pfx.

This is the error I got:
Cannot import the following key file: myfile.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_A422D1337C0DEFF95
The solution was quite simple, I installed the key in the Jenkins server:
sn -i myfile.pfx VS_KEY_A422D1337C0DEFF95
sn is the .NET Framework Strong Name Utility and can be found here:


C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\sn.exe

Since I try to keep the build server as clean as possible, I just copied the tool to the server, be sure to copy the 1033 folder too.

Note that if you don't use password protected signing keys this problem will not occur.

No comments:

Post a Comment