sign command allows you to digitally sign your built Native Desktop applications for Windows and macOS. Code signing is essential for ensuring user trust, preventing security warnings, and meeting platform distribution requirements.
Prerequisites
Before signing your application, ensure:- Your application has been built using
native-desktop build - You have valid code signing certificates for your target platform
- You have the necessary credentials and identities configured
Basic Usage
To sign an application, run:bin/ directory.
Command Options
[app-path] (Optional)
Path to the application to sign.
- Type: String (positional argument)
- Required: No (auto-detected if not provided)
- Example:
bin/MyApp.dmg,bin/MyApp.exe
--platform
Target platform for signing.
- Type: String
- Choices:
windows,mac - Required: No (auto-detected from app path)
--verbose
Enable verbose logging for detailed signing information.
- Type: Boolean
- Default:
false
macOS Signing
Signing macOS applications requires an Apple Developer certificate and optionally Apple ID credentials for notarization.Required Credentials
- Developer ID Application Certificate: For signing the application
- Apple ID (optional): For notarization
- Team ID (optional): For notarization
macOS Options
--identity
Certificate identity name or hash for signing.
- Type: String
- Required: Yes (for macOS)
- Format: Certificate name or SHA-1 hash
To find your certificate identity, use:
security find-identity -v -p codesigning--apple-id
Apple ID email address for notarization.
- Type: String
- Required: No (required for notarization)
--apple-id-password
Apple ID app-specific password for notarization.
- Type: String
- Required: No (required for notarization)
--team-id
Apple Team ID for notarization.
- Type: String
- Required: No (required for notarization)
macOS Examples
Basic Signing (No Notarization)
Signing with Notarization
Using Certificate Hash
macOS Notarization
Notarization is an additional security step required for distribution outside the Mac App Store. It involves:- Signing: Application is signed with Developer ID
- Upload: Binary is uploaded to Apple for scanning
- Verification: Apple verifies the application
- Stapling: Notarization ticket is attached to the application
Notarization is required for macOS 10.15+ applications distributed outside the Mac App Store.
Windows Signing
Signing Windows applications requires a code signing certificate in.pfx or .p12 format.
Required Credentials
- Code Signing Certificate:
.pfxor.p12file - Certificate Password: Password for the certificate file
Windows Options
--cert-file
Path to the certificate file (.pfx or .p12).
- Type: String
- Required: Yes (one of cert-file or certificate-sha1)
--cert-password
Password for the certificate file.
- Type: String
- Required: Yes (when using cert-file)
--cert-subject-name
Certificate subject name (alternative to cert-file).
- Type: String
- Required: No
--certificate-sha1
Certificate SHA1 hash (alternative to cert-file).
- Type: String
- Required: No
Windows Examples
Signing with Certificate File
Signing with Certificate Store
Signing with SHA1 Hash
Signing MSI Installer
Automatic Signing During Build
You can automatically sign your application during the build process using the--sign flag:
When using
--sign with the build command, signing credentials must be configured in your native-desktop.config.json5 file.Configuration File Signing
You can configure signing credentials in yournative-desktop.config.json5 file:
Verification
After signing, verify your application:macOS Verification
Windows Verification
Common Issues
macOS: Certificate Not Found
macOS: Certificate Not Found
Error:
Certificate identity not foundSolution: Ensure your Developer ID certificate is installed in Keychain.macOS: Notarization Failed
macOS: Notarization Failed
Error:
Notarization failedSolution: Check that all credentials are correct and the app-specific password is valid.- Verify Apple ID credentials
- Ensure app-specific password is generated
- Check Team ID matches your developer account
- Review verbose logs with
--verbose
Windows: Certificate Password Invalid
Windows: Certificate Password Invalid
Error:
Invalid certificate passwordSolution: Verify the certificate password is correct.Windows: Certificate File Not Found
Windows: Certificate File Not Found
Error:
Certificate file not foundSolution: Provide the correct path to the certificate file.Application Path Not Found
Application Path Not Found
Error:
Application path not foundSolution: Ensure the application has been built and the path is correct.Security Best Practices
Secure Credentials
Never commit certificates or passwords to version control. Use environment variables or secret management tools.
App-Specific Passwords
Use Apple app-specific passwords instead of your main Apple ID password for notarization.
Certificate Protection
Store certificate files securely and restrict access to authorized personnel only.
Regular Renewal
Monitor certificate expiration dates and renew before expiry to avoid distribution issues.
Platform Requirements
macOS
- macOS 10.13+: Required for code signing
- Xcode Command Line Tools: Install with
xcode-select --install - Apple Developer Account: Required for Developer ID certificates
- Internet Connection: Required for notarization
Windows
- Windows 7+: Supported for code signing
- signtool: Included in Windows SDK
- Code Signing Certificate: From trusted Certificate Authority