How to Use the productsign Command in macOS Terminal to Digitally Sign Enterprise PKG Installers

When distributing macOS applications, daemons, or system configurations through Enterprise Mobile Device Management (MDM) platforms (such as Jamf Pro, Kandji, or Microsoft Intune) or directly via web downloads, macOS Gatekeeper requires all installer packages (.pkg) to be digitally signed with a trusted Apple certificate. While codesign signs individual Mach-O binaries and application bundles, flat installer packages must be signed using the specialized productsign command-line utility in macOS Terminal.

Why Installer Signing Differs from Application Signing

An application bundle (.app) contains compiled executables signed with an “Apple Development” or “Developer ID Application” certificate. However, an installer package (.pkg) is an XAR-compressed archive containing package payloads, pre/post-install scripts, and installation destination receipts. macOS Gatekeeper validates the outer package archive using a distinct certificate class: Developer ID Installer. Submitting a package signed with an Application certificate will fail Gatekeeper verification.

Syntax and Key Parameters

productsign --sign <identity> [options] input_package.pkg output_package.pkg
  • --sign <identity> (Required): The common name or SHA-1 hash of your “Developer ID Installer” certificate from Keychain.
  • --timestamp: Embeds a trusted secure cryptographic timestamp from Apple’s timestamp authority (default and mandatory for notarization).
  • --keychain <path>: Specifies an alternative keychain file where the signing private key resides.
  • --cert <cert_name>: Appends intermediate CA certificates into the package signature block.

Step-by-Step Practical Implementation

Step 1: Verify Your Developer ID Installer Certificate

  1. Open Terminal from /Applications/Utilities/.
  2. Query your local macOS login keychain for valid installer signing identities:
    security find-identity -v -p basic
  3. Locate the identity titled:
    "Developer ID Installer: Your Company Name (TEAM_ID)"

Step 2: Signing an Unsigned Installer Package

Run productsign, specifying the signing identity, secure timestamping, the input package, and the desired signed output filename:

productsign --sign "Developer ID Installer: Your Company Name (TEAM_ID)" --timestamp unsigned_app.pkg signed_app.pkg

Terminal queries Apple’s timestamp servers and completes the signature:

productsign: signing product with identity "Developer ID Installer: Your Company Name (TEAM_ID)" from keychain /Users/admin/Library/Keychains/login.keychain-db
productsign: adding certificate "Developer ID Certification Authority"
productsign: adding certificate "Apple Root CA"
productsign: Wrote signed product to signed_app.pkg

Step 3: Verifying the Signed Package with pkgutil

To confirm that the package signature is valid, complete, and trusted by the Apple Root CA:

pkgutil --check-signature signed_app.pkg

Output must confirm:

Status: signed by a developer certificate issued by Apple for distribution
Certificate Chain:
 1. Developer ID Installer: Your Company Name (TEAM_ID)
 2. Developer ID Certification Authority
 3. Apple Root CA

Step 4: Submitting for Notarization and Stapling

Once signed with productsign, the package is ready for notarization via xcrun notarytool, followed by ticket attachment via xcrun stapler staple signed_app.pkg.

macOS Code Signing Utilities Comparison

Command Target Artifacts Required Certificate Type Primary Role
productsign Flat installer packages (.pkg) Developer ID Installer Signing deployment archives and MDM distribution packages
codesign Mach-O binaries, .app bundles, .dylib Developer ID Application Signing executable code, frameworks, and app bundles
pkgbuild Component files / raw payloads Can sign via --sign at build Building and packaging payloads into component packages
productbuild Distribution XML + Component PKGs Can sign via --sign at build Assembling multi-package distribution suites

Troubleshooting Common Errors

  • “Could not find a identity matching…”: Ensure you are using a “Developer ID Installer” certificate and not a “Developer ID Application” certificate.
  • Keychain Lock Error: When running in automated SSH or CI/CD runner sessions, unlock your keychain first using: security unlock-keychain -p <password> ~/Library/Keychains/login.keychain-db.
  • Timestamp Timeout: If the signing process hangs or fails with a timestamp error, verify that outgoing HTTPS access to Apple’s timestamp authority (timestamp.apple.com) is not blocked by local firewalls.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.