Log date · Mon
Does a hardened macOS app need notarization again?
Published on · Updated
Yes, if hardening changes signed code: re-sign it and notarize the new distribution build. We tested signature checks and policy assessment.
Does a hardened macOS app need notarization again?
If hardening changes signed code, finish the transformation, sign again, and notarize the new distribution build. After we changed a string in our own binary, codesign verification changed from exit 0 to exit 1; an ad hoc re-sign brought it back to 0. All three spctl assessments ended in an internal error, so they tell us neither whether Gatekeeper would accept nor reject the app.
| Question | Finding |
|---|---|
| Does the old signature survive a change? | Not in our sample: codesign returned 1. |
| What did re-signing fix? | Local signature integrity verification passed again. |
| Did spctl accept it? | Unknown: all three attempts reported an internal error. |
| Does ad hoc signing equal notarization? | No; notarization requires an appropriate Developer ID signature. [1] |
Sample and test scope
On an arm64 Mac running macOS 27.2, Xcode 27.2 and Apple clang 21.0.0, we compiled a C program that prints a fixed string and compared its original, modified and re-signed states using ad hoc signing; we did not submit to Apple’s notary service or test a real app bundle, distribution certificate or installation.
We replaced an embedded string with another of the same length. This represents a post-signing file change, not the full behavior of a hardening tool. We rebuilt the sample from source and recorded output, errors and exit codes for each check, so a tool failure is not mistaken for a pass.
clang -o sample sample.c
codesign --force --sign - sample
codesign --verify --verbose=2 sample
spctl --assess --type execute --verbose=4 sampleWhat changed after the edit
The first codesign verification says the sample on disk satisfies its own signature requirement. After the string change, verification explicitly reports an invalid signature; after re-signing it passes again. The following lines are output from our run.
== original signature ==
sample: valid on disk
sample: satisfies its Designated Requirement
codesign exit: 0
sample: internal error in Code Signing subsystem
spctl exit: 1
== modified file ==
sample: invalid signature (code or signature have been modified)
In architecture: arm64
codesign exit: 1
sample: internal error in Code Signing subsystem
spctl exit: 1== re-signed file ==
sample: valid on disk
sample: satisfies its Designated Requirement
codesign exit: 0
sample: internal error in Code Signing subsystem
spctl exit: 1An ad hoc signature here establishes consistency with that signature, not a Developer ID identity or an Apple notarization ticket. codesign checks signature integrity, while spctl assesses system policy; they answer different questions. An internal error calls for investigation of the assessment environment. Exit 1 alone must not be reported as a Gatekeeper rejection.
Put signing and notarization in the right order
Produce and harden the final code first, then sign nested components and the enclosing app. Apple’s distribution signing guide says to sign nested code before the code that contains it; inspect each helper, framework and plug-in and its entitlements rather than examining only the outer file. [2] If a later step changes signed content, return to signing and verification for the affected components.
For direct distribution, Apple’s notarization preparation requirements include valid Developer ID signatures, the Hardened Runtime, a secure timestamp and correctly formed entitlements. [1] Hardened Runtime is a macOS runtime protection, not a synonym for a third-party code transformation. Choose only the entitlements the software needs, and check plug-ins, JIT and library loading in particular instead of enabling exceptions indiscriminately.
Apple’s notary service automatically scans for malicious content and checks signing issues. It is neither App Review nor a score for resistance to reverse engineering. [1] Keep separate evidence for signatures, notarization, policy assessment and functional testing so a failure can be traced to the right stage.
Do not use --deep as a substitute for signing each item: Apple notes that it applies the same signing options to items and can miss code in nonstandard locations. The option can help with verification, but a verification pass does not prove that every component received the appropriate entitlements. Apple also says entitlements belong on main executables and should not be applied indiscriminately to library code. [2]
Submission, logs and stapling
Apple’s command-line workflow uses notarytool to submit a supported container, wait for processing and retain the submission ID; inspect the log for warnings even after success. After acceptance, stapler can attach the ticket to an app, disk image or installer package so Gatekeeper can find it offline. [3] The example below follows the documentation and was not executed; the profile is a preconfigured Keychain item name, not a password to put in a script.
ditto -c -k --keepParent "MyApp.app" "MyApp.zip"
xcrun notarytool submit "MyApp.zip" --keychain-profile "PROFILE" --wait
xcrun notarytool log "SUBMISSION-ID" --keychain-profile "PROFILE" notary-log.json
xcrun stapler staple "MyApp.app"
xcrun stapler validate "MyApp.app"
ditto -c -k --keepParent "MyApp.app" "MyApp-stapled.zip"Apple says a ZIP can be submitted but cannot itself be stapled: staple the app inside, then create the ZIP for distribution again. A standalone binary cannot have a ticket stapled directly either. [3] For a disk image or installer package, plan signing, submission and stapling around the actual container. Upload completion is not acceptance: read the final status and log.
Container choice also affects what the signature covers. Apple explains that a ZIP cannot itself be signed, so files outside the protection of its contents’ code signatures are not protected by a ZIP signature; disk images and installer packages can be signed. Prepare and sign nested containers from inside out. For ordinary nested containers Apple directs developers to notarize the outermost container, while third-party installers have additional steps. [3][4]
Recommendations by release situation
These are release recommendations based on the documentation and our observations, not measured outcomes for every product.
| Question | Finding |
|---|---|
| Hardening after signing | Re-sign affected code and its enclosing bundle, verify again, then submit the new distribution build. |
| Only an ad hoc signature | Use it for local integrity experiments; use the appropriate Developer ID signature for direct distribution. |
| Accepted with warnings | Inspect the log, address warnings and test the final package. |
| spctl reports an internal error | Preserve the full output and investigate the environment; do not treat it as acceptance or an ordinary rejection. |
| ZIP distribution | Staple the app, rebuild the archive and check the ZIP users receive. |
Check your own app
On a copy of a release build you are authorized to inspect, replace the path with your app. Check its signature, then assess policy and validate the ticket separately. Retain complete output, exit codes, build identity and a digest of the distribution package. The example below is for your own app and was not run against our standalone binary.
codesign --verify --deep --strict --verbose=2 "MyApp.app"
codesign -d --verbose=4 "MyApp.app"
spctl --assess --type execute --verbose=4 "MyApp.app"
xcrun stapler validate "MyApp.app"
shasum -a 256 "MyApp-stapled.zip"After verification, download and install through the real distribution channel on a separate clean Mac. Check first launch, permission prompts, plug-ins, updates and core functions, as well as target architectures and offline behavior. Apple recommends testing on a different Mac where possible so development data does not affect the outcome. [4] Keep the notarization ID, log and final package digest together so the record identifies what users actually receive.
Your checklist
- Finish code transformations, then sign nested code and the app inside out.
- Check Developer ID, Hardened Runtime, timestamp and required entitlements.
- Submit the final build and retain notarization status, ID and log.
- Staple the ticket, rebuild the ZIP and verify the final distribution.
- Test installation, first launch, updates and offline behavior on another Mac.
Primary sources
- Apple: Notarizing macOS software before distribution · Checked 2026-11-11
- Apple: Creating distribution-signed code for macOS · Checked 2026-11-11
- Apple: Customizing the notarization workflow · Checked 2026-11-11
- Apple: Packaging Mac software for distribution · Checked 2026-11-11