Cannot load PFX key for assembly signing

murarialex's Avatar

murarialex

05 Jun, 2020 11:18 PM

Hello,

I'm trying to add a PFX key for strong-signing my .NET assemblies through Import-PfxCertificate, it's being imported correctly, but when MsBuild starts, it cannot load the certificate and gives the following message:
"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_689BEEB655EEA138".

But if it was imported correctly, why msbuild can't use it?

The build log: https://ci.appveyor.com/project/alexmurari/repositive/builds/33350366
The appveyor.yml file: https://github.com/alexmurari/Repositive/blob/dev/appveyor.yml#L41

Thanks

  1. Support Staff 1 Posted by Feodor Fitsner on 05 Jun, 2020 11:56 PM

    Feodor Fitsner's Avatar

    Never seen such an error before. Try looking via RDP how the cert is installed: https://www.appveyor.com/docs/how-to/rdp-to-build-worker/

  2. 2 Posted by murarialex on 06 Jun, 2020 12:43 AM

    murarialex's Avatar

    After some more digging I fixed it by using this script:

    https://github.com/camalot/madb/blob/master/.appveyor/modules/Impor...

    Loading PFX files isn't as simple as it should be.

    Apparently this problem has already popped up here some time ago: https://help.appveyor.com/discussions/problems/1350-strange-behavio....

    Strange to have to use such complicated scripts for trivial tasks like signing assemblies. Anyway, it's working now.

  3. Support Staff 3 Posted by Feodor Fitsner on 06 Jun, 2020 12:47 AM

    Feodor Fitsner's Avatar

    Maybe it depends on the certificate, as in our internal builds we are importing AppVeyor's signing certificate with just Import-PfxCertificate. However, we are signing with signtool.exe, not during the build, so this might be the difference as well.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac