Monday, May 17, 2010

Visual Studio error 'Cannot find the certificate and private key for decryption'

I have a perfectly good (and expensive) Thwate Code Signing Certificate - but when I try to import it into Visual Studio to sign an assembly I get a daft error of the form of the title above. I thought MS might have fixed this in VS2010 but no.

The problem appears to be that the certificate holds too much information for VS to comprehend, so you need to import the Certificate onto your machine and export it without all this extra "stuff".

The solution is to run CertMgr.msc - import your certificate - (usually into Personal->Certificates) and then:
export it by right clicking on the certificate you just imported ->All Tasks ->Export->Yes Export Private Key->
(Do not include any Personal Information Exchange check boxes)
Type a password and export it to a folder (preferably in your VS Project)

Now, in Visual Studio->Signing->Strong Name Key File-> try and browse to your new key and it should load after you enter the password.

5 comments:

Anonymous said...

thanks a lot

Anonymous said...

thanks a lot

Anonymous said...

thanks a lot

Anonymous said...

thanks a lot! I had exactly the same problem...

Anonymous said...

Very helpful, thanks