Overview
Code signing is essential for distributing desktop applications. It verifies that your application comes from a trusted source and hasn’t been tampered with. Different platforms have different requirements:- macOS: Requires code signing and notarization for Gatekeeper
- Windows: Requires code signing to avoid SmartScreen warnings
- Linux: Optional, but recommended for some distributions
macOS Code Signing
NativePHP includes built-in support for macOS code signing and notarization using Apple’s notarytool.Prerequisites
Developer Certificate
Obtain a “Developer ID Application” certificate from your Apple Developer account.
App-Specific Password
Generate an app-specific password for notarization at appleid.apple.com.
Configuration
Set the following environment variables in your.env file:
.env
Your Team ID can be found in your Apple Developer account under Membership Details.
Notarization Process
NativePHP automatically handles notarization after the build is signed:Entitlements
NativePHP includes macOS entitlements for common permissions:These usage descriptions appear in permission dialogs when your app requests access to protected resources.
Platform Detection
The notarization script only runs when building for macOS:Windows Code Signing
Windows code signing prevents SmartScreen warnings and establishes trust with your users.Traditional Code Signing
Requirements:- A valid code signing certificate from a trusted CA (DigiCert, Sectigo, etc.)
- The certificate in PFX format with password
.env
Azure Trusted Signing (Cloud-Based)
NativePHP supports Azure Trusted Signing, a cloud-based code signing solution:.env
- Traditional Certificate
- Azure Trusted Signing
Pros:
- One-time purchase
- Works offline
- Full control over private key
- Certificate management complexity
- Risk of key compromise
- Annual renewal required
Building Reputation
Even with a valid certificate, Windows SmartScreen may show warnings for new applications. Building reputation requires:- Consistent Signing: Always sign with the same certificate
- User Downloads: More users downloading and running your app
- Time: Reputation builds over weeks/months
- Extended Validation (EV) Certificate: Provides instant reputation
EV certificates provide immediate SmartScreen reputation but are more expensive and require hardware tokens.
Linux Code Signing
Linux doesn’t have platform-wide code signing requirements, but some distributions support it:AppImage Signing
AppImages can be signed with GPG:Debian Package Signing
For.deb packages, you can sign with dpkg-sig:
Linux signing is optional but recommended for enterprise distributions and repositories.
Security Best Practices
Protect Your Signing Credentials
Protect Your Signing Credentials
- Never commit signing credentials to version control
- Use environment variables or secure secret management
- Rotate app-specific passwords regularly
- Use hardware security modules (HSMs) for production
Clean Environment Variables
Clean Environment Variables
NativePHP automatically removes signing credentials from your bundled
.env file:Separate Development and Production
Separate Development and Production
- Use different certificates for development and production
- Don’t sign development builds
- Sign only final release builds
Verify Signed Applications
Verify Signed Applications
After signing, verify your applications:macOS:Windows:
CI/CD Integration
For automated builds, store signing credentials in your CI/CD secrets:GitHub Actions Example
Troubleshooting
macOS Notarization Fails
Issue: Notarization returns errors from Apple. Solutions:- Verify your Apple ID and app-specific password are correct
- Ensure your Team ID matches your Developer account
- Check that your app bundle ID matches
NATIVEPHP_APP_ID - Review Apple’s notarization logs for specific issues
Windows SmartScreen Warnings
Issue: Users see “Windows protected your PC” warnings. Solutions:- Verify your certificate is properly installed
- Check that the certificate is from a trusted CA
- Build reputation over time with consistent signing
- Consider an EV certificate for instant reputation
Missing Environment Variables
Issue: Notarization is skipped..env file.
Next Steps
Auto-Updates
Configure automatic updates for your signed applications
Build Configuration
Learn about build configuration options