Electron Desktop Application Signing and Notarization
🎯 Introduction
Packaging generates application files. Signing tells the operating system who published the app and confirms that its files have not changed since signing. macOS also requires notarization, which submits the app to Apple for inspection so the system can recognize its approval.
This article walks through signing on macOS and Windows separately. You do not need to publish for both systems; start with the one available to you.
Keep three points in mind:
- Forge cannot produce a valid production signature without a certificate.
- Certificates and passwords must not be committed to the repository.
- You can skip signing for local learning and complete signing and platform checks before public distribution.
🧱 Signing workflow overview
The basic workflow is similar on either system:
Obtain and install a certificate
↓
Configure signing in Forge
↓
Generate an installer
↓
Verify the signature
↓
Test installation on a clean system
macOS adds notarization:
Sign on macOS → Submit to Apple for notarization → Download the notarization result → Verify
🍎 macOS: Signing and notarization
Step 1: Where to obtain an Apple certificate
To distribute to users' computers, join the Apple Developer Program, then request a certificate under Certificates, Identifiers & Profiles → Certificates in your Apple Developer account.
Follow these steps:
- Sign in to your Apple Developer account.
- Open Certificates, Identifiers & Profiles → Certificates.
- Click the plus button at the top right.
- Select Developer ID Application.
- Create a certificate signing request (
.certSigningRequest) as instructed. - Upload the request and download the generated
.cerfile. - Double-click the
.cerfile to install it in macOS Keychain Access.
Developer ID Application signs Mac apps. Do not select a certificate intended only for the Mac App Store. See Apple's instructions: Developer ID certificates.
After installing the certificate on your Mac, check it with:
security find-identity -p codesigning -v
If the list includes Developer ID Application, the current Mac has a certificate available for application signing.
Step 2: Let Forge use the certificate
Add osxSign: {} to packagerConfig in forge.config.js:
module.exports = {
packagerConfig: {
icon: './assets/icon',
osxSign: {},
},
};
osxSign: {} tells Forge to use a signing certificate already installed on the current Mac. It does not create a certificate; it enables macOS signing during packaging.
Run packaging:
npm run package
Step 3: Verify the signature
Replace the path below with the actual .app path generated in out:
codesign --verify --deep --strict --verbose=2 \
'out/electron-course-darwin-arm64/Electron Course.app'
If no error appears, code signature verification passed. This does not mean notarization is complete; you still need the next step.
Step 4: Where to submit for macOS notarization
Notarization happens through Apple's Notary Service, which inspects the signed app, rather than through an Electron Forge web page. Forge calls Apple's service for you, but you must supply authentication credentials.
Two authentication methods are common; choose one when learning:
- Apple ID + app-specific password + Team ID.
- App Store Connect API Key。
To use an API key, sign in to App Store Connect, go to Users and Access → Integrations → App Store Connect API → Team Keys, and create and download a key. The private key can be downloaded only once, so store it securely. See Apple's instructions.
The example below uses an Apple ID and an app-specific password:
module.exports = {
packagerConfig: {
osxSign: {},
osxNotarize: {
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_APP_SPECIFIC_PASSWORD,
teamId: process.env.APPLE_TEAM_ID,
},
},
};
Set these environment variables in the current terminal, then run:
export APPLE_ID='your-apple-account'
export APPLE_APP_SPECIFIC_PASSWORD='your-app-specific-password'
export APPLE_TEAM_ID='your-team-id'
npm run make
The variables are:
APPLE_ID: Your Apple account email address.APPLE_APP_SPECIFIC_PASSWORD: An app-specific password generated for your Apple account, rather than your login password.APPLE_TEAM_ID: The Team ID in your Apple Developer account.
Forge signs the app and submits it for notarization during packaging. Once notarization finishes, check whether the system accepts the app:
spctl --assess --type execute --verbose \
'out/electron-course-darwin-arm64/Electron Course.app'
What to remember on macOS
osxSignhandles signing.osxNotarizesubmits the app to Apple for notarization.- Signing certificates and notarization credentials are separate things.
- Successful signing does not imply successful notarization.
🪟 Windows: Sign the installer
Step 1: Where to obtain a Windows certificate
Obtain a Windows certificate from a code signing certificate provider rather than Electron Forge. Select a Windows Code Signing Certificate; after approval, you typically receive a .pfx certificate file and its password.
Microsoft also offers a cloud signing service, subject to region, account, and organization eligibility requirements. For now, remember that you first need a valid Windows signing identity from a certificate provider or Microsoft's signing service.
See Electron Forge's Windows signing guide: Signing a Windows app.
Certificates are commonly supplied as .pfx files with a password.
Keep the .pfx file outside the project or in a secure directory excluded from Git. Do not copy it into assets or put its password in forge.config.js.
Step 2: Configure Forge
Set the certificate path and password in the Windows Squirrel maker:
module.exports = {
makers: [
{
name: '@electron-forge/maker-squirrel',
config: {
certificateFile: process.env.WINDOWS_CERTIFICATE_FILE,
certificatePassword: process.env.WINDOWS_CERTIFICATE_PASSWORD,
},
},
],
};
Environment variables keep the password out of source code and Git history.
Step 3: Generate a signed installer
Run in Windows PowerShell:
$env:WINDOWS_CERTIFICATE_FILE = 'C:\certs\electron-course.pfx'
$env:WINDOWS_CERTIFICATE_PASSWORD = 'your-certificate-password'
npm run make
Forge uses this certificate when generating the Squirrel.Windows installer. After generation, verify the signature using Windows signing tools:
signtool verify /pa .\out\make\squirrel.windows\x64\*.exe
Use the actual path and filename of the artifact in out.
🔐 Pre-release security checks
Before releasing a signed app, check at least the following:
[ ] Certificate files are not committed to Git
[ ] Certificate passwords are absent from source code
[ ] The macOS app passes codesign verification
[ ] The macOS app is notarized for public distribution
[ ] The Windows installer passes signtool verification
[ ] Installation and startup work on a clean system without development tools
[ ] The signed app still updates and uninstalls correctly
With CI/CD, configure certificates and passwords as encrypted CI secrets, and let build scripts read only environment variables.
🧾 Summary
- Signing requires real platform certificates; Forge uses them to sign during packaging.
- macOS uses
osxSignand usually also needsosxNotarizefor public distribution. - Windows configures the Squirrel maker with a
.pfxfile and password. - Verify final signatures with system tools rather than relying only on Forge's successful exit.
- Store certificates and passwords securely and never commit them to Git.
❓ Questions and answers
Q1: Can I learn Electron without a certificate?
Yes. Start with npm run package and npm run make. Signing can wait until public distribution.
Q2: Are macOS signing and notarization the same thing?
No. Signing establishes the app's origin; notarization lets Apple inspect the app and record the result.
Q3: Why shouldn't a .pfx file be stored in the project?
A .pfx file usually contains a private key. If exposed, someone else could impersonate your publisher identity.
Q4: Does successful Forge packaging guarantee successful signing?
No. Verify the final artifact with codesign or signtool.
🧪 Practice
Exercise 1: Run the certificate lookup command on your development machine to check whether a usable signing certificate exists.
Exercise 2: Check that .gitignore excludes local certificate files, environment variable files, and signing logs.
🎉 You now understand how certificates, Forge configuration, builds, and verification fit together in Electron signing.
