title: Windows - Code signing guide locally & with Github Actions
import Alert from '@theme/Alert'
Code-signing will add a level of authenticity to your application, while it is not required it can often improve the user experience for your users.
There are a few things we will have to do to get our windows installation prepared for code signing. This includes converting our certificate to a speific format, installing this certificate, & then decoding required information from certificate that is required by tauri.
.cer
to .pfx
You will need the following:
cert.cer
)private-key.key
)Open up a command prompt and change to your current directory using cd Documents/Certs
Convert your .cer
to a .pfx
using openssl pkcs12 -export -in cert.cer -inkey private-key.key -out certificate.pfx
You will be prompted to enter an export password DON'T FORGET IT!
.pfx
file into the keystore.We will now need to import our .pfx
file.
Assign your export password to a variable using $WINDOWS_PFX_PASSWORD = 'MYPASSWORD'
Now Import the certificate using Import-PfxCertificate -FilePath Certs/certificate.pfx -CertStoreLocation Cert:\LocalMachine\My -Password (ConvertTo-SecureString -String $env:WINDOWS_PFX_PASSWORD -Force -AsPlainText)
We will need the SHA-1 thumbprint of the certificate, you can get this using openssl pkcs12 -info -in certificate.pfx
and look under for following
Bag Attributes
localKeyID: A1 B1 A2 B2 A3 B3 A4 B4 A5 B5 A6 B6 A7 B7 A8 B8 A9 B9 A0 B0
You will capture the localKeyID
but with no spaces, in this example it would be A1B1A2B2A3B3A4B4A5B5A6B6A7B7A8B8A9B9A0B0
. This is our certificateThumbprint
.
We will need the SHA digest algorythm used for your certificate (Hint: this is likely sha256
We will also need a timestamp url, this is a time server used to verify the time of the certificate signing. Im using http://timestamp.comodoca.com
but whoever you got your certificate from likely has one aswell.
tauri.conf.json
fileNow that we have our certificateThumbprint
, digestAlgorithm
, & timestampUrl
we will open up the tauri.conf.json
.
In the tauri.conf.json
you will look for the tauri
-> bundle
-> windows
section. You will see there are three variable for the information we have captured. Fill it out like below.
"windows": {
"certificateThumbprint": "A1B1A2B2A3B3A4B4A5B5A6B6A7B7A8B8A9B9A0B0",
"digestAlgorithm": "sha256",
"timestampUrl": "http://timestamp.comodoca.com"
}
Save, and run yarn | yarn build
In the console output you will see the following output.
info: signing app
info: running signtool "C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.19041.0\\x64\\signtool.exe"
info: "Done Adding Additional Store\r\nSuccessfully signed: APPLICATION FILE PATH HERE
which shows you have successfully signed the .exe
.
And thats it! You have successfully signed your .exe file.