Why Code Signing Matters
Code signing provides several important benefits:- User Trust: Signed applications show users that the software comes from a verified source
- Security: Prevents tampering and malware injection after distribution
- Operating System Requirements:
- macOS Gatekeeper only allows apps from identified developers
- Windows SmartScreen warns users about unsigned applications
- Auto-Updates: Properly signed applications enable seamless auto-update functionality
Environment Variables
electron-builder uses environment variables for code signing configuration:| Environment Variable | Description |
|---|---|
CSC_LINK | The HTTPS link (or base64-encoded data, or file:// link, or local path) to certificate (*.p12 or *.pfx file). Shorthand ~/ is supported (home directory). |
CSC_KEY_PASSWORD | The password to decrypt the certificate given in CSC_LINK. |
CSC_NAME | macOS only - Name of certificate (to retrieve from login.keychain). Useful on a development machine (not on CI) if you have several identities (otherwise don’t specify it). |
CSC_IDENTITY_AUTO_DISCOVERY | true or false. Defaults to true — on a macOS development machine valid and appropriate identity from your keychain will be automatically used. |
CSC_KEYCHAIN | The keychain name. Used if CSC_LINK is not specified. Defaults to system default keychain. |
WIN_CSC_LINK | Windows certificate link when building on macOS (if different from CSC_LINK). |
WIN_CSC_KEY_PASSWORD | Windows certificate password when building on macOS (if different from CSC_KEY_PASSWORD). |
If you are wrapping your app into an installer (
.pkg), you need to have INSTALLER ID identity in your keychain or provide CSC_INSTALLER_LINK and CSC_INSTALLER_KEY_PASSWORD.If you are building Windows apps on macOS and need to set a different certificate and password than the ones in
CSC_* env vars, use WIN_CSC_LINK and WIN_CSC_KEY_PASSWORD.Setting Up Code Signing on CI/CD
To sign your app on build servers like Travis CI, AppVeyor, GitHub Actions, or CircleCI:Export your certificate
Export your certificate to a
.p12 file.Consider avoiding special characters in the password, as values are not escaped when your builds are executed.Encode the certificate
Encode the file to base64:Alternatively, upload your
*.p12 file (e.g., on Google Drive) and use a direct link generator to get the correct download link.Configure environment variables
Set
CSC_LINK and CSC_KEY_PASSWORD environment variables in your CI project settings:If you use a link to a file (not base64 encoded data), escape special characters using:Certificate Types
macOS Certificates
macOS uses Apple-issued certificates from the Apple Developer Program:- Developer ID Application: Sign apps for distribution outside the Mac App Store
- Developer ID Installer: Sign installer packages for distribution outside the Mac App Store
- 3rd Party Mac Developer Application: Sign apps for Mac App Store submission
- 3rd Party Mac Developer Installer: Sign installer packages for Mac App Store
- Apple Distribution: Sign apps for Mac App Store (newer certificate type)
- Mac Developer / Apple Development: Sign development builds for testing
Gatekeeper only recognizes Apple digital certificates. You must have an Apple Developer account.
Windows Certificates
Windows supports two types of certificates:- Standard Code Signing Certificate: Regular certificate that works with auto-update. Shows a warning during installation until your app builds trust with users.
- EV (Extended Validation) Code Signing Certificate: Higher trust level, works immediately without warnings. However, it’s bound to a physical USB dongle and cannot be exported for CI builds.
Where to Buy Certificates
Windows
See Microsoft’s guide: Get a code signing certificate Platform: “Microsoft Authenticode” Popular certificate authorities:- DigiCert
- Sectigo
- SSL.com
- GlobalSign
macOS
macOS certificates are obtained through the Apple Developer Program ($99/year).Alternative Code Signing Methods
While electron-builder provides automated code signing through configuration, some developers prefer GUI tools:- SSL Manager - SSL.com’s signing tool
- DigiCert Utility for Windows - DigiCert’s certificate management tool
Next Steps
Windows Code Signing
Learn how to sign Windows applications
macOS Code Signing
Learn how to sign and notarize macOS applications