Menu

Visual Studio – signing assembly problem

28.2.2017 - C#, Programování

When you want sing you application you can user any certificate for sign but in most time can occur problem in visual studio which cannot uset your cerfificate.

Here is workarround which works perfectly

http://stackoverflow.com/a/39196724

 

(here is copy)

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:

  1. Open Command Prompt with admin privileges.
  2. Type command: certutil -importPFX "<certFilepath>\<certFilename>.p12" AT_SIGNATURE(AT_SIGNATURE is what makes this work instead of [Right-click .p12 file]–>’Install PFX‘)
  3. Type a password of your choice.
  4. Open mmc.exe with admin privileges, File–>Add/Remove Snap-in…
  5. Add ‚Certificates‘
  6. Choose ‚Computer Account‘
  7. Under Console Root/Certificates (Local Computer)/Personal/Certificates locate your certificate installed by step 2.
  8. Right click Cert/All Tasks/Export–>Next/Yes, export the private key
  9. Go to ‚Personal Information Exchange – PKCS #12 (.PFX)‘
  10. Uncheck ‚Include all certificates…‘. Important! If checked VS will produce this message: „Cannot find the certificate and private key for decryption“ when signing.
  11. Check ‚Export all extended properties‘ (Optional).
  12. You can check ‚Delete the private key…‘ if you are not planning to re-export in the future.
  13. Tick password and type the password of step 3.
  14. Choose file path and file name for the exported (.pfx) certificate.
  15. Use exported .pfx file to sign your assembly/project from VS.
  16. Build project to make sure that pfx works properly.