Skip to main content
Code signing is a critical security feature that ensures users can trust your application. Both macOS and Windows code signing are fully supported in electron-builder. If the configuration values are provided correctly, signing is performed automatically during the build process.

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 VariableDescription
CSC_LINKThe 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_PASSWORDThe password to decrypt the certificate given in CSC_LINK.
CSC_NAMEmacOS 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_DISCOVERYtrue or false. Defaults to true — on a macOS development machine valid and appropriate identity from your keychain will be automatically used.
CSC_KEYCHAINThe keychain name. Used if CSC_LINK is not specified. Defaults to system default keychain.
WIN_CSC_LINKWindows certificate link when building on macOS (if different from CSC_LINK).
WIN_CSC_KEY_PASSWORDWindows 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:
1

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.
2

Encode the certificate

Encode the file to base64:
# macOS
base64 -i yourFile.p12 -o envValue.txt

# Linux
base64 yourFile.p12 > envValue.txt
Alternatively, upload your *.p12 file (e.g., on Google Drive) and use a direct link generator to get the correct download link.
3

Configure environment variables

Set CSC_LINK and CSC_KEY_PASSWORD environment variables in your CI project settings:
Set these variables in your CI Project Settings, not in .travis.yml or appveyor.yml files.
If you use a link to a file (not base64 encoded data), escape special characters using:
printf "%q\n" "<url>"
In AppVeyor, click the lock icon to “Toggle variable encryption” for sensitive values.
Windows cannot handle environment variable values longer than 8192 characters. If the base64 representation of your certificate exceeds this limit, re-export the certificate without including all certificates in the certification path (the Certificate Manager export wizard enables this option by default, but they are not necessary).

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: These tools can be useful for manual signing workflows or certificate management.

Next Steps

Windows Code Signing

Learn how to sign Windows applications

macOS Code Signing

Learn how to sign and notarize macOS applications

Build docs developers (and LLMs) love