Code signing is required for macOS applications to work with auto-update.
Environment Variables
Code signing is configured using environment variables:| Environment Variable | Description |
|---|---|
CSC_LINK | The HTTPS link, base64-encoded data, file:// link, or local path to certificate (*.p12 or *.pfx file). Supports ~/ shorthand for 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 development machines with multiple identities (not needed on CI). |
CSC_IDENTITY_AUTO_DISCOVERY | true or false. Defaults to true — on macOS development machines, a 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. |
Additional Environment Variables
If you are wrapping your app into a macOS installer (pkg), you need to have an
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 different certificates, use
WIN_CSC_LINK and WIN_CSC_KEY_PASSWORD instead of the generic CSC_* variables.CI Server Configuration
To sign your app on CI servers (Travis, AppVeyor, GitHub Actions, etc.), you need to setCSC_LINK and CSC_KEY_PASSWORD:
Export your certificate
Export your certificate to a
.p12 file.Encode the certificate
Encode the certificate file to base64:Alternatively, upload the
*.p12 file to a cloud storage service (e.g., Google Drive) and use a direct link generator to get a download link.Windows Certificate Length Limitation
CI Configuration Examples
GitHub Actions
.github/workflows/build.yml
Travis CI
.travis.yml
AppVeyor
appveyor.yml
Where to Buy Code Signing Certificates
Windows
For Windows code signing, you need an Authenticode certificate:- Microsoft Documentation: Get a code signing certificate
- Platform: “Microsoft Authenticode”
- Popular providers:
- DigiCert
- Sectigo (formerly Comodo)
- GlobalSign
- SSL.com
macOS
For macOS code signing, you need an Apple digital certificate:- Join the Apple Developer Program ($99/year)
- Create a Developer ID Application certificate in your Apple Developer account
- Download and install the certificate in your Keychain Access
Certificate Types
macOS:- Developer ID Application: For distributing outside the Mac App Store
- Mac App Distribution: For distributing through the Mac App Store
- Developer ID Installer: For creating signed installers (pkg files)
- Code Signing Certificate: For signing executables and installers
- EV Code Signing Certificate: Extended Validation certificate (no SmartScreen warnings)
Alternative Code Signing Methods
Code signing via electron-builder configuration is not the only approach. Some developers prefer GUI tools:Third-Party Tools
- SSL.com eSigner - Cloud-based code signing
- SSL Manager - Certificate management tool
- DigiCert Certificate Utility for Windows - Windows certificate management
Comprehensive discussion of third-party signing tools is beyond the scope of this documentation. Refer to the tool’s documentation for usage instructions.
macOS Notarization
Starting with macOS 10.15 (Catalina), apps must be notarized by Apple to run without warnings:package.json
APPLE_ID: Your Apple ID emailAPPLE_APP_SPECIFIC_PASSWORD: App-specific password from Apple IDAPPLE_TEAM_ID: Your Apple Team ID
Troubleshooting
Verify Certificate Installation (macOS)
Verify Signature (macOS)
Verify Signature (Windows)
Common Issues
macOS:- “No identity found”: Certificate not installed in keychain or
CSC_NAMEdoesn’t match - “User interaction is not allowed”: Keychain is locked on CI; use
CSC_LINKwith base64-encoded certificate - “Notarization failed”: Check that
APPLE_IDcredentials are correct and app meets notarization requirements
- “Certificate not found”:
CSC_LINKpath is incorrect or certificate is malformed - “Invalid password”:
CSC_KEY_PASSWORDis incorrect - “Unsupported algorithm”: Certificate uses an unsupported signature algorithm; obtain a new certificate