On a macOS development machine, a valid and appropriate identity from your keychain is automatically used. If no identity exists:
- ARM or universal builds: An ad-hoc signature is applied by default
- Intel-only builds: No signing by default
Understanding macOS Code Signing
macOS requires apps to be signed with Apple-issued certificates from the Apple Developer Program. This ensures:- Apps pass Gatekeeper security checks
- Users can verify the app’s authenticity
- The app can be notarized for distribution
- Localized descriptions display correctly
Certificate Types
Different distribution methods require different certificate types:| Certificate Type | Usage |
|---|---|
| Developer ID Application | Sign apps for distribution outside the Mac App Store |
| Developer ID Installer | Sign installer packages (.pkg) for distribution outside the Mac App Store |
| 3rd Party Mac Developer Application | Sign apps for Mac App Store submission (legacy) |
| Apple Distribution | Sign apps for Mac App Store submission (current) |
| 3rd Party Mac Developer Installer | Sign installer packages for Mac App Store |
| Mac Developer / Apple Development | Sign development builds for testing MAS submissions (mas-dev target) |
You can import multiple certificates into your keychain or CI environment. electron-builder will automatically select the appropriate certificate for your build target.
Exporting Certificates from Keychain
To use your certificates on CI or another machine:Select certificates
- Select the
loginkeychain in the left sidebar - Select the
My Certificatescategory - Select all required certificates using Cmd+Click:
Developer ID Application:for apps outside Mac App StoreDeveloper ID Installer:for installers outside Mac App StoreApple Distributionor3rd Party Mac Developer Application:for Mac App Store apps3rd Party Mac Developer Installer:for Mac App Store installersApple Development:orMac Developer:for development testing
Select all certificates you need in a single export. All selected certificates will be imported into the temporary keychain on your CI server.
Export certificates
- Right-click on the selected certificates
- Choose “Export” from the context menu
- Save as
.p12format - Set a strong password (you’ll need this for
CSC_KEY_PASSWORD)
Development Machine Setup
On your Mac development machine, signing typically works automatically:Automatic Identity Discovery
By default,CSC_IDENTITY_AUTO_DISCOVERY=true, so electron-builder will:
- Search your keychain for valid signing identities
- Select the appropriate certificate for your build target
- Sign your application automatically
Specifying a Certificate Name
If you have multiple identities and want to use a specific one:CSC_NAME should be the name portion after the certificate type prefix (e.g., just “Your Company Name”, not “Developer ID Application: Your Company Name”).CI/CD Setup
For build servers without keychain access:Export and encode certificate
Follow the “Exporting Certificates from Keychain” steps above to get a base64-encoded
.p12 file.Configure notarization (recommended)
For apps distributed outside the Mac App Store, configure notarization:Or use the newer notarytool API key method:
Disabling Code Signing
Sometimes you may want to build unsigned (e.g., for testing):Method 1: Environment Variable
Method 2: Configuration
In yourelectron-builder config:
Method 3: Ad-Hoc Signing (ARM/Universal)
For ARM or universal builds, use ad-hoc signing instead of no signature:Notarization
For apps distributed outside the Mac App Store, Apple requires notarization:What is Notarization?
Notarization is an automated security check by Apple:- Apple scans your app for malicious content
- If it passes, Apple adds a “ticket” to your app
- Gatekeeper verifies this ticket when users run your app
- Required for macOS 10.15+ to avoid warnings
Notarization Setup
electron-builder handles notarization automatically when you provide credentials:Option 1: App-Specific Password (Recommended)
Create an app-specific password at appleid.apple.com:
- Sign in with your Apple ID
- Navigate to Security → App-Specific Passwords
- Generate a new password
Option 2: API Key
Download API keys from App Store Connect:
- Users and Access → Keys
- Create a new key with “Developer” access
- Download the
.p8file (you can only download it once)
Hardened Runtime Requirements
Notarized apps must use the hardened runtime with appropriate entitlements. Exampleentitlements.mac.plist:
Mac App Store Signing
For Mac App Store distribution:Use correct certificates
- Apple Distribution or 3rd Party Mac Developer Application for the app
- 3rd Party Mac Developer Installer for the installer
Add provisioning profile
Download your provisioning profile from Apple Developer and place it in your project root or specify its path:
Configure entitlements
Mac App Store apps require specific entitlements. Create
entitlements.mas.plist:Troubleshooting
No Valid Signing Identity Found
If electron-builder reports no valid identity:-
Check available identities:
-
Verify certificate is valid:
- Open Keychain Access
- Find your certificate in My Certificates
- Ensure it shows as valid (not expired)
- Check that the private key is present
-
Force discovery:
Certificate Chain Issues on CI
If builds fail with certificate chain errors:- Ensure you’re on macOS (not Linux) for macOS builds
- Check that the root certificate keychain is being added
- Verify your
.p12file includes the private key
Notarization Fails
Common notarization issues:- Missing entitlements: Add required hardened runtime entitlements
- Invalid bundle ID: Ensure bundle ID matches your certificate
- Unsigned native modules: All native dependencies must be signed
- Invalid credentials: Verify
APPLE_IDand password are correct
Video Tutorial
Watch this community-created tutorial on macOS code signing and notarization:Additional Resources
- Notarizing your Electron application by Kilian Valkhof
- Apple’s Notarization Documentation
- Apple’s Code Signing Guide
Next Steps
Windows Code Signing
Learn about Windows code signing
Publishing
Publish your signed app to distribution channels