Cannot add certificate to Cert:\CurrentUser\My

VS2017 code signing (performed by a Cordova Windows build) expects the code signing certificate in Cert:\CurrentUser\My. Running this on a local machine works without problems, but on the Travis Windows environment it seems to be impossible because I cannot add the certificate to Cert:\CurrentUser\My.

I’ve tried adding the certificate in Travis with both certutil:

certutil -user -p mypassword -importpfx mycertificate.pfx

and with a powershell script:

Import-PfxCertificate -FilePath $Pfxpath -CertStoreLocation Cert:\CurrentUser\My -Password $Password

but both methods fail. It is possible to add the certificate to Cert:\LocalMachine\My but then VS2017 does not pick up the certificate and ends with a couple error messages.

warning APPX0105: Cannot import the key file 'mycertificate.pfx'. The key file may be password protected. To correct this, try to import the certificate manually into the current user's person al certificate store.
warning APPX0102: A certificate with thumbprint '1234567890123456789012345678901234567890' that is specified in the project cannot be found in the certificate store. Please specify a valid thumbprint in the project file.
warning APPX0107: The certificate specified is not valid for signing. For more information about valid certificates, see

Is there a way to fix this problem?

1 Like

Please include a build link. Copypasting things here gives incomplete information.

Sure, I understand. Give me some time to prepare a test case and I’ll share that over here.

As promised here is the test case and a couple build logs. In all cases the code signing step, or certificate import step fails.

Test case:

Code signing fails, no certificate imported:

Code signing fails, certificate imported into LocalMachine:

Code signing fails, certificate import into CurrentUser fails (certutil):

Code signing fails, certificate import into CurrentUser fails (powershell):


I got this to work with GitHub Actions, see here:

Okay, this one took a while.

@BanzaiMan @kris It looks like1 when preparing build VM’s image, you are cleaning out AppData\* directories. You should not do that for AppData\Roaming\Microsoft\Crypto – this is what is causing this error. It turns out, Win10’s rsaenh.dll, unlike Win7, is expecting to always find a couple of certain files there.

1Since Windows builder is not in, I cannot say for sure – or offer a patch