Signing assemblies with strong name using pfx and visual studio
I own a Comodo (.p12) certificate and ran into the same issue and solved it based on @SmithPlatts answer and @Ares comment. Here is a detailed walkthrough for those who are not savvy (like me) with certificates:
- Open Command Prompt with admin privileges.
- Type command:
certutil -importPFX "<certFilepath>\<certFilename>.p12" AT_SIGNATURE
(AT_SIGNATURE is what makes this work instead of [Right-click .p12 file]-->'Install PFX') - Type a password of your choice.
- Open mmc.exe with admin privileges, File-->Add/Remove Snap-in...
- Add 'Certificates'
- Choose 'Computer Account'
- Under Console Root/Certificates (Local Computer)/Personal/Certificates locate your certificate installed by step 2.
- Right click Cert/All Tasks/Export-->Next/Yes, export the private key
- Go to 'Personal Information Exchange - PKCS #12 (.PFX)'
- Uncheck 'Include all certificates...'. Important! If checked VS will produce this message: "Cannot find the certificate and private key for decryption" when signing.
- Check 'Export all extended properties' (Optional).
- You can check 'Delete the private key...' if you are not planning to re-export in the future.
- Tick password and type the password of step 3.
- Choose file path and file name for the exported (.pfx) certificate.
- Use exported .pfx file to sign your assembly/project from VS.
- Build project to make sure that pfx works properly.
I have just encountered the same issue and this article saved my bacon!
All I needed to do was recreate my Code Signing cert with KeySpec set to 2 (AT_SIGNATURE) and now VS (2013) imports and signs my assembly without error! :-D
I realize that this is a bit different to your scenario, but I hope this can help in some way ...