Renew Windows 10 PFX certificate for Cordova App with Visual Studio

This article explains how to renew the PFX certificate for your Windows 10 / 8.1 app created with Tools for Apache Cordova in Visual Studio. The certificate is valid for just one year, so it must be renewed to rebuild the app.

Symptoms

You receive the following error when building your Windows (Tools for Apache Cordova) app from Visual Studio, targeting Windows 10:

Warning APPX0108 The certificate specified has expired. For more information about renewing certificates, see http://go.microsoft.com/fwlink/?LinkID=241478

Cause

The default certificate that Visual Studio generates expires one year after the date on which the certificate was created. If you try to build your app after that year, the build will process will fail.

Resolution

Follow these steps to create a new certificate valid for another year:

Close your Tools for Apache Cordova project from the File > Close Solution menu.

Go to File > Open > Project/Solution. Select the CordovaApp.sln file from the platforms/windows folder and open it:

CordovaApp.sln

CordovaApp.sln is the solution file created by Visual Studio

In the Solution Explorer, you should see a series of solutions for different platforms:

Visual Studio Solution Explorer for Windows 10 and Windows Universal

Visual Studio Solution Explorer

Expand any of them and locate the package.windows.appxmanifest file. Open it by double clicking on it.

Switch to the Packaging tab, locate the Publisher section, and click the Choose Certificate button. A dialog like this will show up:

Visual Studio Choose Certificate

Visual Studio Choose Certificate

From the Configure Certificate drop down, select Create test certificate and enter your certificate’s Publisher Common Name and password:

Visual Studio Create Test Certificate

Visual Studio Create Test Certificate

You should use the same Common Name from your previous certificate. Save this file from the File menu and close it.

For the other platforms

If you have other platforms created, such as Windows 8.1, you can either:

  • Repeat the same process to create new certificates
  • Reuse the PFX certificate you’ve just created in the previous platform

Note: I’m not sure of the implications of reusing the same certificate, but that’s the option I prefer to use and I had no problems with it so far.

After updating all certificates, select File > Save All and close the solution. Now open your Tools for Apache Cordova solution, and run a test build, the certificate error APPX0108 should be gone.

References

The certificate renewal process, along with other options, can also be found in the Renew a Certificate section from the Manage the certificates that Visual Studio uses to sign your app Microsoft Docs article.