Skip to content
CoreMacs
Security & signingExplainer

Notarizing a macOS app with notarytool: what changed and how to automate it

Apple's notary service stopped accepting uploads from altool on November 1, 2023. This explainer covers what notarization checks, how notarytool stores credentials, waits for results and fetches logs, why stapling matters, and how to script it in CI.

CoreMacs News Desk·Published ·Last verified ·5 min read
A silver Mac Studio on a grey desk beside a display, a white keyboard, a notebook and a potted plant.

Notarization is Apple's automated security check for Mac software distributed outside the Mac App Store. The notary service scans Developer ID-signed apps, disk images and installer packages for malicious content and code-signing problems; if it finds none, it issues a ticket that Gatekeeper can find online or stapled to the file. Apple stresses that this is not App Review. Since macOS 10.15, Developer ID software built after June 1, 2019 must be notarized, and in macOS Sequoia users can no longer Control-click past Gatekeeper for software that is not correctly signed or notarized.

What changed: altool retired for notarization, notarytool in

Apple introduced notarytool at WWDC 2021 and first shipped it with Xcode 13. Starting November 1, 2023, the notary service stopped accepting uploads from altool or Xcode 13 or earlier; Apple's announcement pointed developers to notarytool or Xcode 14 or later. The WWDC22 session that announced the cutoff, then set only for fall 2023, said it covered notarization with every form of altool and uploads from the Xcode 13 interface, while notarytool, including the copy in Xcode 13, would keep working. Previously notarized software keeps working.

Apple's migration note, TN3147, lists the practical differences and says altool still suits other jobs, such as submitting an app to the App Store; Apple's App Store Connect help still lists it for uploading builds. Credentials are the same kinds: an app-specific password or an App Store Connect API key. --primary-bundle-id has no replacement, because the service never used it. Submission IDs and history are separate from altool's, and there is no completion email: use --wait or --webhook.

What the notary service requires

Apple's notarization guide requires:

  • valid signatures on every executable, made with a Developer ID certificate, not a Mac Distribution, ad hoc or development one;
  • the Hardened Runtime for app and command-line targets;
  • a secure timestamp in the signature;
  • no com.apple.security.get-task-allow entitlement set to true;
  • linking against the macOS 10.9 SDK or later, with well-formed XML entitlements.

Xcode's archive and export flow handles most of this. For manual signing, Apple's guide to distribution-signed code says to sign nested code first, pass --timestamp, add -o runtime for main executables and avoid --deep when signing. The Hardened Runtime blocks some capabilities, such as JIT compilation, unless you add the matching exception entitlement.

Storing notarytool credentials

On a persistent build Mac, save credentials once as a named profile. With an Apple ID, notarytool prompts for the app-specific password and validates it:

xcrun notarytool store-credentials "notary-ci" \
  --apple-id "[email protected]" --team-id "TEAMID"

For an App Store Connect API key, pass --key (the .p8 file), --key-id and --issuer; the man page says the issuer ID is required for team keys and must be left out for individual keys. Later commands take --keychain-profile "notary-ci", and --keychain selects a specific keychain file. TN3147 recommends testing with xcrun notarytool history. On throwaway runners, passing the key options directly is simpler.

Submitting with --wait and reading the log

The service does not accept a bare .app, so Apple's workflow guide zips it with ditto. Disk images and signed flat installer packages can be submitted as they are.

ditto -c -k --keepParent "MyApp.app" "MyApp.zip"
xcrun notarytool submit "MyApp.zip" --keychain-profile "notary-ci" --wait
xcrun notarytool log <submission-id> --keychain-profile "notary-ci" notary-log.json

--wait returns only when processing ends, which removes polling; --timeout caps the wait. The JSON log lists each issue with a severity, path and message. Read it even when the status is Accepted; Apple notes it can contain warnings. Apple reports that most software finishes within 5 minutes and 98 percent within 15 minutes, and asks developers to limit notarizations to 75 per day.

Stapling the ticket and checking Gatekeeper

Gatekeeper can fetch the ticket online; stapling attaches it so the check also works offline.

xcrun stapler staple "MyApp.app"
xcrun stapler validate "MyApp.app"
spctl -vvv --assess --type exec "MyApp.app"

Apps, disk images and flat installer packages can be stapled. ZIP archives cannot, so staple the app and zip it again; standalone binaries currently cannot be stapled either. For nested containers, Apple's packaging guide says to notarize only the outermost one.

Common rejection messages and fixes

Log messageUsual fix
The signature of the binary is invalid.Sign everything, and do not change the bundle after signing.
The binary is not signed with a valid Developer ID certificate.Use Developer ID Application, or Developer ID Installer for packages.
The signature does not include a secure timestamp.Sign with --timestamp.
The executable does not have the hardened runtime enabled.Enable the capability or sign with -o runtime.
The executable requests the com.apple.security.get-task-allow entitlement.Archive or export through Xcode, or set CODE_SIGN_INJECT_BASE_ENTITLEMENTS to NO for distribution builds.

Apple's troubleshooting page recommends testing signatures with codesign -vvv --deep --strict, or pkgutil --check-signature for installer packages.

A minimal CI script outline

This sketch assumes a signed, exported app and a team App Store Connect API key from the CI secret store. Like Apple's sample archive script, it reads plist output with PlistBuddy.

set -eu
APP="build/MyApp.app"
codesign -vvv --deep --strict "$APP"
ditto -c -k --keepParent "$APP" upload.zip

xcrun notarytool submit upload.zip \
  --key "$ASC_KEY_PATH" --key-id "$ASC_KEY_ID" --issuer "$ASC_ISSUER_ID" \
  --wait --timeout 2h --output-format plist > notary.plist || true
STATUS=$(/usr/libexec/PlistBuddy -c "Print :status" notary.plist)
ID=$(/usr/libexec/PlistBuddy -c "Print :id" notary.plist)

xcrun notarytool log "$ID" \
  --key "$ASC_KEY_PATH" --key-id "$ASC_KEY_ID" --issuer "$ASC_ISSUER_ID" \
  notary-log.json
[ "$STATUS" = "Accepted" ] || exit 1

xcrun stapler staple "$APP"
ditto -c -k --keepParent "$APP" MyApp-notarized.zip

Apple's sample script reads only status and message, so inspect notary.plist once to confirm the submission ID key. Delete the key file when the job ends. On restricted networks, Apple's guides list addresses to allow, including the S3 upload endpoint, the CloudKit ranges that stapler uses and timestamp.apple.com.

Sources

Share