Certificate in windows .pfx file has EKU issue

2019-09-13 19:47发布

问题:

I have developed an application in phonegap and now I want to release it for windows phones. But as we know that since Windows 10 was introduced we have to make a .pfx file to sign an application.

I have created a certificate with OpenSSL and as I try to build my application with that key I am getting this error:

Error - Your Windows Signing Key must have an EKU (Enhanced Key Usage) property of "Code Signing"

I don't know what does exactly mean. Can anyone please help me out for this?

回答1:

EKU (Enhanced Key Usage) is certificate Extensions which determine what the certificate is intended to be used for. For signing other applications, Windows expects the cert to contain Code Signing EKU extension.

I suppose you are using a self signed certificate. You can use following commands to generate a pfx file which would contain a certificate for your use. Although I'm not sure if a self signed certificate can be used to push an application on windows app store

First of all save following content in a file name "code_signing". This file is configuration file for your certificate. Change the fields under "my dn"

[ req ]
prompt             = no
distinguished_name = my dn

[ my dn ]
commonName = secure.example.com
countryName = XX
localityName = XXX
organizationName = Org Name
organizationalUnitName = BU Name
stateOrProvinceName = YY
emailAddress = mail@example.com
name = name
surname = surName
givenName = name

[code_signing]
extendedKeyUsage = 1.3.6.1.5.5.7.3.3

The last line extendedKeyUsage = 1.3.6.1.5.5.7.3.3 specifies the EKU for code Signing. Now use following to generate a private key and certificate using above config file

openssl req -x509 -config code_signing -extensions 'code_signing' -nodes -days 365 -newkey rsa:2048 -keyout private.key -out certificate.crt

Now use the generated private.key and certificate.crt to generate your pfx file

openssl pkcs12 -export -out codeSigning.pfx -inkey private.key -in certificate.crt