Windows applications are dual code-signed using both SHA1 and SHA256 hashing algorithms for maximum compatibility.
Certificate Types
There are two types of Windows code signing certificates:Standard Code Signing Certificate
- Works with auto-update functionality
- More affordable option
- Shows a warning during installation until trust is established
- The warning disappears once enough users have installed your application
- Can be exported for use on CI servers
- Best for: Most applications, CI/CD workflows
EV (Extended Validation) Code Signing Certificate
- Works with auto-update functionality
- Higher trust level - works immediately without warnings
- More expensive than standard certificates
- Bound to a physical USB dongle (hardware token)
- Cannot be exported for CI builds
- Requires
win.certificateSubjectNameconfiguration - Best for: Enterprise applications, when immediate trust is critical
Prerequisites
Standard Certificate Signing
For standard code signing certificates that can be exported:Obtain your certificate
Purchase a code signing certificate from a trusted Certificate Authority:
- DigiCert
- Sectigo (formerly Comodo)
- SSL.com
- GlobalSign
.pfx or .p12 file with a strong password.Set environment variables
Configure the following environment variables:For CI/CD, encode your certificate to base64:Then set
CSC_LINK to the base64 string.If building Windows apps on macOS/Linux and using different credentials, set
WIN_CSC_LINK and WIN_CSC_KEY_PASSWORD instead of the standard CSC_* variables.EV Certificate Signing
For Extended Validation certificates with hardware tokens:Connect the hardware token
Ensure your EV certificate’s USB hardware token is connected to the build machine.
Configure certificateSubjectName
In your The subject name must match exactly what’s in your certificate. To find it:
electron-builder configuration, specify the certificate subject name:- Open Certificate Manager (certmgr.msc)
- Navigate to Personal → Certificates
- Double-click your certificate
- Use the “Issued to” name exactly as shown
Azure Trusted Signing (Beta)
Microsoft offers a cloud-based code signing service called Azure Trusted Signing, which is an excellent option for CI/CD workflows.Setup Overview
Create Azure Trusted Signing Account
Follow Microsoft’s quickstart guide to set up a Trusted Signing Account.
Create App Registration
Set up an App registration in Azure:
- Create the App registration
- Create a “Secret” for it (save the secret value)
- Assign the role “Trusted Signing Certificate Profile Signer” to the App registration
The App registration is considered a “service principal” - you’ll need to search for its name to find it in the role assignment panel.
Configure electron-builder
Add Azure Trusted Signing configuration to your Configuration properties:
electron-builder config:| Property | Description |
|---|---|
publisherName | Must match exactly the CommonName (CN) property of your certificate |
endpoint | The endpoint you selected when creating your certificate |
certificateProfileName | The name of the certificate profile in your Trusted Signing Account |
codeSigningAccountName | The name of the Trusted Signing Account (NOT the app registration name) |
Set environment variables
Configure authentication environment variables (for service principal with secret):For other authentication methods, see Azure.Identity EnvironmentCredential documentation.
These environment variables are read directly by the
Invoke-TrustedSigning PowerShell module.If both
azureSignOptions and signtoolOptions are configured, azureSignOptions takes precedence and signtoolOptions will be ignored.Code Signing on Unix Systems
You can sign Windows applications from macOS or Linux:Use standard certificate
EV certificates (hardware tokens) cannot be used on Unix systems. Use a standard exportable certificate instead.
Troubleshooting
Certificate Not Found
If electron-builder cannot find your certificate:- Verify the certificate is in the correct keystore
- Check that
CSC_LINKpoints to the correct file - Ensure
CSC_KEY_PASSWORDis correct - For EV certificates, verify
certificateSubjectNamematches exactly
Environment Variable Length Limit
If your base64-encoded certificate exceeds this limit:- Re-export your certificate
- Uncheck “Include all certificates in the certification path if possible”
- The extra certificates in the chain are not necessary
Build Fails with “Couldn’t resolve host name”
This is a transient network error. electron-builder automatically retries signing operations up to 3 times with exponential backoff.File Being Used by Another Process
This can occur on Windows when:- Antivirus software is scanning the file
- Multiple build processes are running simultaneously
Example Configuration
Next Steps
macOS Code Signing
Learn about macOS code signing and notarization
Auto Update
Set up auto-update with signed applications