How to sign a Windows UWP Ionic application?

I have a previous post asking for UWP documentation here, but as we can see it has not had much interest.

I more specific question is “how to do the signing?”

I have spent hours trying to get this to work (a related stack overflow issue on this is here - I just cannot get signtool to work. I have been trying to follow these instructions, but as in the linked issue, it just does not work. Also, I am still concerned about the statement there “A self signed certificate is useful for testing your app” - is uses the words to test, which indicates this is not for final distribution to the store (although others say self signed is ok)

I notice the UWP build does have a certificate same folder as the .appx (ie CordovaApp.Windows10_1.0.1.1_x86.cer). Are we mean to just use this somehow?

Since the appx it create from the Ionic build, I am hoping someone here may have been through this and know how to get it working?

Thanks in advance for any help!

Same as you sign a Windows UWP Cordova application - because that is what Ionic builds:
https://cordova.apache.org/docs/en/7.x/guide/platforms/win8/index.html#signing-an-app
You might have more luck googling for that as well. Hopefully.

@Sujan12 thanks for the suggestions. The link (https://cordova.apache.org/docs/en/7.x/guide/platforms/win8/index.html#signing-an-app) has got me closer as it mentions the use of the build.config file. But the MS doco here only shows how to create a self signed, which is states "A self signed certificate is useful for testing " - but I want one for distribution. This is probably why it is not working, I can just find nothing on how to use a proper certificate (I don’t mind if I have to purchase or whatever, as long as I know what to do)

I have been googling for days, following all sorts of instructions for creating and importing certificates, and just nothing works, I cannot get the build to use a certificate I create using the exact scripts.

Anyway, I carry on.

I am now very close. The only remaining issues I seem to have is

  1. The icon is wrong, infact it seems to be looking for an Android icon. I get the following warning

     The following image was skipped because it has an unsupported size (undefinedxundefined): 
     resources\android\icon\drawable-xhdpi-icon.png
     Building project: H:\dev\myapp\platforms\windows\CordovaApp.Windows10.jsproj
    
  2. http/https does not appear to be able to connect to my server

I’ll put these as separate posts if I can’t find an answer.

Below is what I had to do. The big thing for me is that the self signed certificate just does appear to be valid

The doco on certificates for UWP at https://docs.microsoft.com/en-au/windows/uwp/packaging/create-certificate-package-signing
seems to suggest (as have others on forums) you can use a self signing, but this just did not work for me. We are using an existing certificate we have already purchased (and use for other .net assembly signing purposes)

The best info is found here…
https://cordova.apache.org/docs/en/latest/guide/platforms/win8/ (thanks @Sujan12)

I’ve put the certificate and buidl.config files are in the folder windows_certificate under the project root

So to add and build windows

  1. Add the platform (ionic cordova platform add windows)

  2. Make sure we add <preference name="windows-target-version" value="10.0" /> to config.xml

  3. We need to use the build.config as suggested in the Cordova doco. Add the flag
    –buildConfig windows_certificate\build.config
    to the build command

  4. Important! We must import our certificate on the machine doing the signing
    As suggested at the Cordova doc, use
    certutil -user -p <password> -importPFX <certificatename>.pfx

  5. Full release/production build command is
    ionic cordova build windows --prod --release -- --arch=x86 --buildConfig windows_certificate\\build.config

  6. The file we upload is platforms/windows/AppPackages/CordovaApp.Windows10_0.0.1.0_x86.appxupload
    (this file has a .appx inside of it)

2 Likes