How to create an app package signing certificate
You must digitally sign your Windows Store apps before you deploy them. If you don't use Microsoft Visual Studio 2012 to create and sign your app packages, you need to create and manage your own code signing certificates. You can create certificates by using MakeCert.exe and Pvk2Pfx.exe from the Windows Driver Kit (WDK). Then you can use the certificates to sign the app packages, so they can be deployed locally for testing.
To make the signing certificate that you create usable with the app package that you want to sign, the subject name of the signing certificate must match the Publisher attribute of the Identity element in the AppxManifest.xml for that app. For example, suppose the AppxManifest.xml contains:
<Identity Name="Contoso.AssetTracker" Version="188.8.131.52" Publisher="CN=Contoso Software, O=Contoso Corporation, C=US"/>
For the publisherName parameter that you specify with the MakeCert utility in the next step, use "CN=Contoso Software, O=Contoso Corporation, C=US".
Note This parameter string is specified in quotes and is both case and whitespace sensitive.
The Publisher attribute string that is defined for the Identity element in the AppxManifest.xml must be identical to the string that you specify with the MakeCert /n parameter for the certificate subject name. Copy and paste the string where possible.
Use the MakeCert utility to create a self-signed test certificate and private key:
MakeCert /n publisherName /r /h 0 /eku "184.108.40.206.220.127.116.11.3,18.104.22.168.4.1.322.214.171.124" /e expirationDate /sv MyKey.pvk MyKey.cer
This command prompts you to provide a password for the .pvk file. We recommend that you choose a strong password and keep your private key in a secure location.
We recommend that you use the suggested parameters in the preceding example for these reasons:
Creates a self-signed root certificate. This simplifies management for your test certificate.
- /h 0
Marks the basic constraint for the certificate as an end-entity. This prevents the certificate from being used as a Certification Authority (CA) that can issue other certificates.
Sets the Enhanced Key Usage (EKU) values for the certificate.
Note Don't put a space between the two comma-delimited values.
- 126.96.36.199.188.8.131.52.3 indicates that the certificate is valid for code signing. Always specify this value to limit the intended use for the certificate.
- 184.108.40.206.4.1.3220.127.116.11 indicates that the certificate respects lifetime signing. Typically, if a signature is time stamped, as long as the certificate was valid at the point when it was time stamped, the signature remains valid even if the certificate expires. This EKU forces the signature to expire regardless of whether the signature is time stamped.
Sets the expiration date of the certificate. Provide a value for the expirationDate parameter in the mm/dd/yyyy format. We recommend that you choose an expiration date only as long as necessary for your testing purposes, typically less than a year. This expiration date in conjunction with the lifetime signing EKU can help to limit the window in which the certificate can be compromised and misused.
For more info about other options, see MakeCert.
Pvk2Pfx /pvk MyKey.pvk /pi pvkPassword /spc MyKey.cer /pfx MyKey.pfx [/po pfxPassword]
The MyKey.pvk and MyKey.cer files are the same files that MakeCert.exe created in the previous step. By using the optional /po parameter, you can specify a different password for the resulting .pfx; otherwise, the .pfx has the same password as MyKey.pvk.
For more info about other options, see Pvk2Pfx.
After you create the .pfx file, you can use the file with SignTool to sign an app package. For more info, see How to sign an app package using SignTool. But the certificate is still not trusted by the local computer for deployment of app packages until you install it into the trusted certificates store of the local computer. You can use Certutil.exe, which comes with Windows.
To install certificates with WindowsCertutil.exe
- Run Cmd.exe as administrator.
- Run this command:
Certutil -addStore TrustedPeople MyKey.cer
We recommend that you remove the certificates if they are no longer in use. From the same administrator command prompt, run this command:
Certutil -delStore TrustedPeople certID
The certID is the serial number of the certificate. Run this command to determine the certificate serial number:
Certutil -store TrustedPeople
By adding a certificate to local machine certificate stores, you affect the certificate trust of all users on the computer. We recommend that you install any code signing certificates that you want for testing app packages to the Trusted People certificate store. Promptly remove those certificates when they are no longer necessary, to prevent them from being used to compromise system trust.
- Create app package sample
- Code-Signing Best Practices
- How to sign an app package using SignTool
- Signing an app package
Build date: 11/15/2012