You built a Rust desktop app, zipped it, sent it to a friend with a Mac, and macOS refused to open it, or showed an alert saying Apple cannot check it for malicious software. Or you started signing it yourself and codesign answered with this:
Developer ID Application: <Your Name> (<TEAM_ID>): no identity found
The fix for both is the same chain: a Developer ID Application certificate, a signature with the hardened runtime and a secure timestamp, notarization by Apple, and a stapled ticket. That last error, in my case, meant the certificate was named after my LLC, not after me. This article walks the chain by hand on a Mac first, so you can see each link work, then moves it into a GitHub Actions job that runs on every version tag. It is for an independent developer shipping a Rust app outside the Mac App Store. It assumes you can build your app with cargo and have a Mac to do the one-time setup on.
Last verified: December 2026. Versions: GitHub’s macos-latest label (the macOS 26 Arm64 image, Xcode 26.6 default per its readme), Rust 1.100.1 (the runner image’s readme lists Rust 1.98.0 preinstalled; add rustup update stable to the job or pin a toolchain if you need newer), actions/checkout@v7 (v7.0.1), actions/upload-artifact@v7 (v7.0.2). macOS tools cannot run where this article was written: every command was checked against Apple’s documentation and man pages, the workflow was parsed with PyYAML and each run block passed bash -n. It is documentation-verified, not run. My own pipeline, which this is based on, ran end to end at release v0.1.9.
What Happened
I was approved for the Apple Developer Program under Laudenslager Software, LLC, and I needed the launcher for my software shop to open cleanly on Macs. The first pass, by hand on my Mac, stalled in places the documentation does not mention.
codesign failed with no identity found because I passed my personal name. security find-identity -v -p codesigning listed the identity under the LLC’s name, since the company owns the team. The password codesign then asked for was my login keychain password, not anything Apple-account related. An interrupted attempt left an orphaned file ending in .cstemp, which I had to delete.
Notarization produced the strangest stall. After more than 30 minutes, xcrun notarytool history still listed my submission as In Progress, while xcrun notarytool log <submission-id> for the same submission already returned "status": "Accepted". I stapled, and spctl reported accepted with source=Notarized Developer ID. I do not know why history lagged. I only know that log told the truth first.
Moving to CI had two more snags. Keychain Access would not offer Personal Information Exchange (.p12) until the private key was in the selection, and AppIcon.icns turned out to be in .gitignore, so a runner would never have seen it. After that, the launcher’s workflow assembled the .app, signed it with my Developer ID Application certificate imported from the .p12, notarized it with notarytool, and stapled it. It worked end to end at release v0.1.9. The same tag-triggered workflow builds Windows (see Azure Artifact Signing in GitHub Actions) and Linux (see Linux release builds: glibc is too new and musl cannot load Wayland).
Two things in my first version I would not copy: I signed with --deep, and CI authenticated to the notary service with my Apple ID and an app-specific password. The steps below use neither, and the How It Works section explains why.
How It Works
The certificate. Apple issues several certificate types, and only one is right for an app you distribute yourself. Per Apple’s certificates page:
| Certificate | Used for |
|---|---|
| Apple Development | Running your app on your own devices during development |
| Apple Distribution, Mac App Distribution | Submitting to the App Store |
| Developer ID Application | Signing a Mac app (and disk images) distributed outside the Mac App Store |
| Developer ID Installer | Signing a .pkg installer distributed outside the Mac App Store |
The notary service only accepts code signed with a Developer ID certificate. Anything else fails with The binary is not signed with a valid Developer ID certificate. You need Developer ID Installer only if you ship a .pkg. The identity is named Developer ID Application: <Team Name> (<Team ID>), and the team name is whoever enrolled: your legal name for an individual enrollment, the legal entity for an organization.
The private key lives in your keychain, and Apple never holds it, the opposite of the Windows service in my pipeline. Anyone with the .p12 and its password can sign code as you. If the certificate expires, apps already signed keep working (that is what the secure timestamp is for). If it is revoked, users can no longer install them.
The hardened runtime. Runtime protections against code injection, library hijacking and memory tampering, switched on with --options runtime. Notarization requires it on every executable. If your app needs something it blocks, such as JIT compilation, you opt out of that one protection with an entitlement.
Entitlements. Key-value pairs embedded in the signature that grant a process a capability. The hardened runtime exceptions are entitlements such as com.apple.security.cs.allow-jit and com.apple.security.cs.disable-library-validation. A typical Rust GUI app needs none, so the commands below pass no entitlements file. Apple’s rules if you do need one: apply it only to executables, never to libraries; include only keys set to true; and never ship com.apple.security.get-task-allow, which lets a debugger attach and makes notarization fail.
Signing order. A bundle’s signature records the signatures of the code nested inside it, so you sign from the inside out: dylibs and helper executables first, the .app last. Apple’s documentation says not to pass --deep when signing, and the codesign man page marks it deprecated for signing since macOS 13. --deep applies the same options and entitlements to every nested item, and it only finds nested code in the locations it expects, so code in the wrong folder goes unsigned. --deep is still right for verifying. My --deep signing worked, but the launcher bundle contains a single executable, so there was nothing for --deep to get wrong.
Notarization. You upload the signed app (inside a zip, disk image or flat package) to Apple’s notary service with xcrun notarytool. It scans for known malware, checks the signing rules above, and issues a ticket for the top-level file and for every signed item inside it. Apple says most submissions finish within 5 minutes and 98 percent within 15. Read the log even on success, because it lists warnings.
notarytool authenticates in one of two ways:
- Apple ID + app-specific password + Team ID. Tied to a person’s Apple Account. Changing that account’s main password revokes every app-specific password, which silently breaks CI.
- App Store Connect API key (
--keypath to a.p8file,--key-id,--issuer). Created by an Admin, revocable on its own, not tied to anyone’s login.
I recommend the API key for CI: it survives password changes, it can be revoked without touching anyone’s Apple Account, and it keeps a personal credential out of your repository secrets. One trap: it must be a Team key. Apple’s App Store Connect documentation says Individual keys cannot use notarytool, and the notarytool man page says passing --issuer with an individual key gets a 401 Unauthorized.
Stapling. xcrun stapler staple writes the ticket into the .app, .dmg or .pkg you ship. You cannot staple a zip archive, and you cannot staple a standalone executable (it still gets a ticket, held by Apple).
What Gatekeeper checks. When a user first opens a quarantined download, Gatekeeper checks that the code is signed by an identified developer and notarized. If the Mac is online, Gatekeeper can find the ticket on Apple’s servers even if you never stapled it, and it checks whether Apple has revoked the app or your certificate. Offline, it can only use a stapled ticket. Apple warns that without one, Gatekeeper might block your app on a Mac with no network.
Every step below creates one link. When something fails, find the broken link.
What changed recently. In macOS Sequoia, Apple removed the old Control-click way to open software that is not signed correctly or notarized. Users now have to go to System Settings > Privacy & Security, scroll down, click Open Anyway, and confirm. That is a lot to ask of a customer, so in my view notarization is mandatory in practice. As of December 2026 that is still the latest change Apple has announced to this behaviour: the macOS 27 Golden Gate release notes list only a new spctl cleanup option under Gatekeeper.
Cost. The Apple Developer Program costs 99 USD per membership year at the time of writing (Apple shows the price in local currency at enrollment, so check the enrollment page). Organizations need a legal entity and a D-U-N-S number. Developer ID certificates and notarization come with the membership.
Prerequisites
- An active Apple Developer Program membership. Creating a Developer ID certificate requires the Account Holder role.
- A Mac with Xcode 13 or later, or the Command Line Tools (
xcode-select --install), forcodesign,notarytoolandstapler. Do not runcodesignwithsudo. - Rust installed with rustup, and a project that builds with
cargo build --release. - An App Store Connect Team API key for notarization. The Account Holder must first request API access under Users and Access > Integrations. Then an Account Holder or Admin generates a key under Team Keys and downloads the
.p8file (it can be downloaded only once). Note the key ID and your Issuer ID, which App Store Connect shows near the top of the Integrations tab. Forum reports say the Developer role is enough for notarization, but Apple does not document a minimum, and a key’s access level cannot be edited after you create it. - Your app name, Cargo binary name, a reverse-DNS bundle identifier and a version. The commands below use
YourApp,your-app,com.example.yourappand1.2.3; replace them with yours.
Step 1: Create the Developer ID Application Certificate
Create the certificate on the Mac that will do the first signing, so the private key lands in its login keychain. On the web: in Certificates, Identifiers & Profiles, click Certificates, click +, choose Developer ID under Software, upload a certificate signing request, download the .cer and double-click it. I used Xcode’s account settings instead (Manage Certificates), which generates the key and request for you. Apple allows up to five Developer ID Application certificates per team, and most people need one.
Find out exactly what the identity is called:
security find-identity -v -p codesigning
1) <40-HEX-CHARACTER-SHA1> "Developer ID Application: <Your Company> (<TEAM_ID>)"
1 valid identities found
Copy the name exactly as printed, or use the 40-character hash. codesign treats exactly 40 hex digits as the certificate’s SHA-1, which sidesteps name matching completely. Make an offline backup of the identity now (Step 8 shows the export). If you lose the private key you have to create a new certificate.
Step 2: Build a Universal Binary
A universal binary holds an arm64 slice for Apple silicon and an x86_64 slice for Intel Macs. macOS 27 runs only on Apple silicon, but Intel Macs stay on macOS Tahoe 26 with security updates, so the x86_64 slice still reaches real users. Note that Rust demoted x86_64-apple-darwin to Tier 2 in Rust 1.90: it is guaranteed to build, not to pass Rust’s test suite.
rustup target add aarch64-apple-darwin x86_64-apple-darwin
export MACOSX_DEPLOYMENT_TARGET=11.0
cargo build --release --target aarch64-apple-darwin
cargo build --release --target x86_64-apple-darwin
mkdir -p dist
lipo -create -output dist/your-app \
target/aarch64-apple-darwin/release/your-app \
target/x86_64-apple-darwin/release/your-app
lipo -archs dist/your-app
x86_64 arm64
MACOSX_DEPLOYMENT_TARGET sets the oldest macOS the binaries support, and rustc honours it. 11.0 is the minimum for Apple silicon anyway, and it matches LSMinimumSystemVersion in the next step. If you only want one architecture, skip lipo and copy the single binary. My launcher ships arm64 only.
Step 3: Assemble the App Bundle
A .app is a directory with a fixed layout: Contents/Info.plist, the executable in Contents/MacOS/, and resources such as the icon in Contents/Resources/. Rust does not create it for you.
APP=dist/YourApp.app
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
cp dist/your-app "$APP/Contents/MacOS/your-app"
cp packaging/AppIcon.icns "$APP/Contents/Resources/AppIcon.icns"
cat > "$APP/Contents/Info.plist" <<'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>your-app</string>
<key>CFBundleIdentifier</key>
<string>com.example.yourapp</string>
<key>CFBundleName</key>
<string>YourApp</string>
<key>CFBundleDisplayName</key>
<string>YourApp</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleShortVersionString</key>
<string>1.2.3</string>
<key>CFBundleVersion</key>
<string>1.2.3</string>
<key>CFBundleIconFile</key>
<string>AppIcon.icns</string>
<key>LSMinimumSystemVersion</key>
<string>11.0</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
EOF
plutil -lint "$APP/Contents/Info.plist"
dist/YourApp.app/Contents/Info.plist: OK
The keys that matter most: CFBundleExecutable must match the file name in Contents/MacOS exactly; CFBundleIdentifier becomes the code-signing identifier, so make it unique reverse-DNS; CFBundlePackageType is always APPL for an app; CFBundleVersion should go up with every release. Apple’s bundle guide also lists CFBundleSignature as expected, a legacy creator code. My launcher’s plist omits it and passed notarization. Keep AppIcon.icns in Git (git check-ignore -v packaging/AppIcon.icns prints nothing when it is not ignored).
Step 4: Sign Nested Code, Then the Bundle
Sign from the inside out. A plain Rust app has no nested code, so the only command you need is the last one. If you ship a dylib or a helper executable inside the bundle, sign it first:
IDENTITY="Developer ID Application: <Your Company> (<TEAM_ID>)"
# Only if you have them (uncomment): nested libraries, then nested helper executables.
# codesign --force --timestamp --sign "$IDENTITY" \
# dist/YourApp.app/Contents/Frameworks/libexample.dylib
# codesign --force --timestamp --options runtime \
# -i com.example.yourapp.helper --sign "$IDENTITY" \
# dist/YourApp.app/Contents/MacOS/helper
# Always: the bundle itself, last.
codesign --force --timestamp --options runtime --sign "$IDENTITY" dist/YourApp.app
dist/YourApp.app: replacing existing signature
--force is needed because the linker usually leaves an ad hoc signature on the binary, and Apple’s advice is to re-sign with -f after lipo. --timestamp gets a secure timestamp from timestamp.apple.com, so the signature stays valid after the certificate expires. It needs network access. My own commands left it out and notarization still accepted them, but the man page says the default is up to the system, so pass it. --options runtime turns on the hardened runtime. -i gives a nested non-bundled executable its own identifier. To add entitlements, append --entitlements YourApp.entitlements to the command for the executable that needs them.
If anything modifies the bundle after this point (copying in an icon you forgot, editing Info.plist), the signature breaks. Sign last.
Step 5: Verify the Signature Locally
codesign --verify --deep --strict --verbose=2 dist/YourApp.app
codesign -dv --verbose=4 dist/YourApp.app 2>&1 | grep -E 'Authority|Timestamp|flags'
dist/YourApp.app: valid on disk
dist/YourApp.app: satisfies its Designated Requirement
CodeDirectory v=20500 size=... flags=0x10000(runtime) hashes=...
Authority=Developer ID Application: <Your Company> (<TEAM_ID>)
Authority=Developer ID Certification Authority
Authority=Apple Root CA
Timestamp=<date and time>
Check three things: flags includes runtime; the first Authority is your Developer ID Application identity; and there is a Timestamp= line (a Signed Time= line instead means no secure timestamp). --strict matches the checks notarization applies.
A Gatekeeper check before notarizing tells you the signing is right and only notarization is missing:
spctl --assess --type execute -vv dist/YourApp.app
dist/YourApp.app: rejected
source=Unnotarized Developer ID
That rejection is expected at this stage.
Step 6: Package and Submit for Notarization
Store the API key credentials in your keychain once. This step and Option B reuse the IDENTITY variable from Step 4, so stay in the same terminal. notarytool copies the key contents into the keychain item, and you can then move the .p8 somewhere safe offline.
xcrun notarytool store-credentials "notary-api" \
--key ~/private_keys/AuthKey_<KEY_ID>.p8 \
--key-id <KEY_ID> \
--issuer <ISSUER_ID>
The service does not accept a bare .app. Pick one container.
Option A, a zip:
ditto -c -k --keepParent dist/YourApp.app dist/YourApp.zip
xcrun notarytool submit dist/YourApp.zip --keychain-profile "notary-api" --wait
Option B, a disk image (what I ship, and what the CI job uses). Sign the app first (Step 4), build the image, sign it, and submit the image. Apple says to notarize only the outermost container:
rm -rf dist/stage
mkdir -p dist/stage
ditto dist/YourApp.app dist/stage/YourApp.app
ln -s /Applications dist/stage/Applications
hdiutil create -volname YourApp -srcfolder dist/stage -ov -format UDZO dist/YourApp.dmg
codesign --force --timestamp -i com.example.yourapp.dmg \
--sign "$IDENTITY" dist/YourApp.dmg
xcrun notarytool submit dist/YourApp.dmg --keychain-profile "notary-api" --wait
ditto is used instead of cp because it preserves symlinks and metadata. The Applications symlink gives users the usual drag-to-install target. UDZO is a compressed read-only image, the format Apple asks third-party disk image tools to produce. --wait keeps notarytool running until the service finishes. It prints progress while it waits and ends with the result, in the shape Apple’s documentation shows:
createdDate: <timestamp>
id: <submission-id>
name: YourApp.dmg
status: Accepted
Read the log either way:
xcrun notarytool log <submission-id> --keychain-profile "notary-api" notary-log.json
On failure the log’s issues array gives the file path and the reason, for example The executable does not have the hardened runtime enabled. Fix it, re-sign, rebuild the container and submit again. If notarytool history disagrees with log, trust log or xcrun notarytool info <submission-id>.
If you prefer the Apple ID method locally, store-credentials also takes --apple-id <you@example.com> --team-id <TEAM_ID> and prompts for an app-specific password. That is what I used on my laptop.
Step 7: Staple and Re-verify
Staple the item you will distribute.
xcrun stapler staple dist/YourApp.dmg
The staple and validate action worked!
For Option A, staple the .app (you cannot staple the zip), then build a fresh zip from the stapled app for distribution:
xcrun stapler staple dist/YourApp.app
rm dist/YourApp.zip
ditto -c -k --keepParent dist/YourApp.app dist/YourApp.zip
Then check what Gatekeeper will think:
spctl --assess --type open --context context:primary-signature -v dist/YourApp.dmg
spctl --assess --type execute -vv dist/YourApp.app
dist/YourApp.dmg: accepted
source=Notarized Developer ID
dist/YourApp.app: accepted
source=Notarized Developer ID
The --type open --context context:primary-signature form is the one Apple’s DTS engineers give for disk images. On macOS 14 and later, syspolicy_check distribution dist/YourApp.app is a more accurate check for the app.
Any binary your app downloads at runtime is a separate product. My launcher downloads another executable, and that file needs its own sign and notarize pass at build time, with the same certificate. A bare executable goes to the notary service inside a ditto zip and cannot be stapled, so Gatekeeper looks its ticket up online.
Step 8: Export the Certificate and Create CI Secrets
A GitHub runner has no access to your keychain, so CI needs a copy of the identity. In Keychain Access, open the login keychain, select My Certificates, and expand your Developer ID Application certificate so its private key shows. Select the certificate and the key together, choose File > Export Items, pick Personal Information Exchange (.p12), and save it to the Desktop as DeveloperID.p12. If that format is greyed out, the private key is not in your selection. That was my stall. Set a strong export password.
Base64-encode the two files for GitHub’s secret store:
base64 -i ~/Desktop/DeveloperID.p12 | pbcopy
# paste into the DEVID_P12_BASE64 secret, then:
base64 -i ~/private_keys/AuthKey_<KEY_ID>.p8 | pbcopy
# paste into ASC_KEY_P8_BASE64
In the repository, go to Settings > Environments, create an environment named release, and add these environment secrets:
| Secret | Value |
|---|---|
DEVID_P12_BASE64 |
base64 of the .p12 |
DEVID_P12_PASSWORD |
the .p12 export password |
ASC_KEY_P8_BASE64 |
base64 of the .p8 |
ASC_KEY_ID |
the API key ID |
ASC_ISSUER_ID |
the Issuer ID |
Environment secrets reach only jobs that name the environment, and Deployment branches and tags can restrict it to v* tags. Environments on private repositories need GitHub Pro, Team or Enterprise; on Free, use repository secrets and delete the environment: line. Then move the .p12 into your offline backup and delete the loose copy.
Step 9: Add the GitHub Actions Job
The job repeats Steps 2 to 7 on a GitHub-hosted runner, with a temporary keychain in place of your login keychain.
The private key exists on the runner only between the import step and the delete step.
Save this as .github/workflows/release.yml (or add the build-macos job to your existing release workflow). macos-latest currently points to the macOS 26 Arm64 image, and its Xcode can link both architectures.
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build-macos:
runs-on: macos-latest
environment: release
timeout-minutes: 60
env:
APP_NAME: YourApp
BIN_NAME: your-app
BUNDLE_ID: com.example.yourapp
MACOSX_DEPLOYMENT_TARGET: "11.0"
steps:
- uses: actions/checkout@v7
- name: Install Rust targets
run: rustup target add aarch64-apple-darwin x86_64-apple-darwin
- name: Build universal binary
run: |
set -euo pipefail
cargo build --release --locked --target aarch64-apple-darwin
cargo build --release --locked --target x86_64-apple-darwin
mkdir -p dist
lipo -create -output "dist/$BIN_NAME" \
"target/aarch64-apple-darwin/release/$BIN_NAME" \
"target/x86_64-apple-darwin/release/$BIN_NAME"
lipo -archs "dist/$BIN_NAME"
- name: Assemble app bundle
run: |
set -euo pipefail
VERSION="${GITHUB_REF_NAME#v}"
APP="dist/$APP_NAME.app"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
cp "dist/$BIN_NAME" "$APP/Contents/MacOS/$BIN_NAME"
cp packaging/AppIcon.icns "$APP/Contents/Resources/AppIcon.icns"
cat > "$APP/Contents/Info.plist" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>$BIN_NAME</string>
<key>CFBundleIdentifier</key>
<string>$BUNDLE_ID</string>
<key>CFBundleName</key>
<string>$APP_NAME</string>
<key>CFBundleDisplayName</key>
<string>$APP_NAME</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleShortVersionString</key>
<string>$VERSION</string>
<key>CFBundleVersion</key>
<string>$VERSION</string>
<key>CFBundleIconFile</key>
<string>AppIcon.icns</string>
<key>LSMinimumSystemVersion</key>
<string>$MACOSX_DEPLOYMENT_TARGET</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
EOF
plutil -lint "$APP/Contents/Info.plist"
- name: Import signing certificate into a temporary keychain
env:
DEVID_P12_BASE64: ${{ secrets.DEVID_P12_BASE64 }}
DEVID_P12_PASSWORD: ${{ secrets.DEVID_P12_PASSWORD }}
run: |
set -euo pipefail
KEYCHAIN_PATH="$RUNNER_TEMP/signing.keychain-db"
KEYCHAIN_PASSWORD="$(openssl rand -base64 32)"
echo "::add-mask::$KEYCHAIN_PASSWORD"
CERT_PATH="$RUNNER_TEMP/cert.p12"
printf '%s' "$DEVID_P12_BASE64" | base64 --decode -o "$CERT_PATH"
security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH"
security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
security import "$CERT_PATH" -k "$KEYCHAIN_PATH" -f pkcs12 \
-P "$DEVID_P12_PASSWORD" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: \
-s -k "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" > /dev/null
security list-keychains -d user -s "$KEYCHAIN_PATH" \
$(security list-keychains -d user | tr -d '"')
rm -f "$CERT_PATH"
IDENTITY="$(security find-identity -v -p codesigning "$KEYCHAIN_PATH" \
| awk '/Developer ID Application/ { print $2; exit }')"
if [ -z "$IDENTITY" ]; then
echo "No Developer ID Application identity in the imported .p12" >&2
exit 1
fi
echo "KEYCHAIN_PATH=$KEYCHAIN_PATH" >> "$GITHUB_ENV"
echo "SIGN_IDENTITY=$IDENTITY" >> "$GITHUB_ENV"
- name: Sign app, build and sign disk image
run: |
set -euo pipefail
APP="dist/$APP_NAME.app"
DMG="dist/$APP_NAME-${GITHUB_REF_NAME}-macos-universal.dmg"
# Nested code first, if you ship any (a plain Rust app has none).
if [ -d "$APP/Contents/Frameworks" ]; then
find "$APP/Contents/Frameworks" -type f -name '*.dylib' -print0 |
while IFS= read -r -d '' lib; do
codesign --force --timestamp --keychain "$KEYCHAIN_PATH" \
--sign "$SIGN_IDENTITY" "$lib"
done
fi
# Then the bundle itself: main executable, Info.plist, resources.
codesign --force --timestamp --options runtime \
--keychain "$KEYCHAIN_PATH" --sign "$SIGN_IDENTITY" "$APP"
codesign --verify --deep --strict --verbose=2 "$APP"
mkdir -p dist/stage
ditto "$APP" "dist/stage/$APP_NAME.app"
ln -s /Applications dist/stage/Applications
hdiutil create -volname "$APP_NAME" -srcfolder dist/stage \
-ov -format UDZO "$DMG"
codesign --force --timestamp --keychain "$KEYCHAIN_PATH" \
--sign "$SIGN_IDENTITY" -i "$BUNDLE_ID.dmg" "$DMG"
echo "DMG=$DMG" >> "$GITHUB_ENV"
- name: Notarize and staple
env:
ASC_KEY_P8_BASE64: ${{ secrets.ASC_KEY_P8_BASE64 }}
ASC_KEY_ID: ${{ secrets.ASC_KEY_ID }}
ASC_ISSUER_ID: ${{ secrets.ASC_ISSUER_ID }}
run: |
set -euo pipefail
KEY_PATH="$RUNNER_TEMP/AuthKey.p8"
printf '%s' "$ASC_KEY_P8_BASE64" | base64 --decode -o "$KEY_PATH"
xcrun notarytool submit "$DMG" \
--key "$KEY_PATH" --key-id "$ASC_KEY_ID" --issuer "$ASC_ISSUER_ID" \
--wait --output-format json > dist/notary-submit.json || true
cat dist/notary-submit.json
SUBMISSION_ID="$(jq -r '.id // empty' dist/notary-submit.json)"
STATUS="$(jq -r '.status // empty' dist/notary-submit.json)"
if [ -n "$SUBMISSION_ID" ]; then
xcrun notarytool log "$SUBMISSION_ID" \
--key "$KEY_PATH" --key-id "$ASC_KEY_ID" --issuer "$ASC_ISSUER_ID" \
dist/notary-log.json
cat dist/notary-log.json
fi
rm -f "$KEY_PATH"
if [ "$STATUS" != "Accepted" ]; then
echo "Notarization status: ${STATUS:-unknown}" >&2
exit 1
fi
xcrun stapler staple "$DMG"
xcrun stapler validate "$DMG"
spctl --assess --type open --context context:primary-signature -vvv "$DMG"
- uses: actions/upload-artifact@v7
with:
name: macos-dmg
path: |
dist/*.dmg
dist/notary-log.json
if-no-files-found: error
- name: Attach to the GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
if gh release view "$GITHUB_REF_NAME" > /dev/null 2>&1; then
gh release upload "$GITHUB_REF_NAME" "$DMG" --clobber
else
gh release create "$GITHUB_REF_NAME" "$DMG" \
--title "$GITHUB_REF_NAME" --notes "Automated release"
fi
- name: Delete temporary keychain
if: always()
run: |
if [ -n "${KEYCHAIN_PATH:-}" ]; then
security delete-keychain "$KEYCHAIN_PATH" || true
fi
rm -f "$RUNNER_TEMP/cert.p12" "$RUNNER_TEMP/AuthKey.p8"
What the keychain commands do, in order:
create-keychain -pmakes a keychain file in$RUNNER_TEMPwith a random, masked password for this run.set-keychain-settings -lut 21600locks it on sleep and after 6 hours, longer than any job.unlock-keychain -punlocks it. A locked keychain on a machine with no GUI is the classic cause oferrSecInternalComponent.import ... -T /usr/bin/codesignimports the certificate and key and lets onlycodesignuse the key. GitHub’s example uses-A, which thesecurityman page calls insecure because any application could use the key.set-key-partition-list -S apple-tool:,apple:,codesign: -s -klets Apple’s tools use the signing key without an access prompt that would hang a headless runner.list-keychains -d user -sadds the keychain to the search list, ahead of the existing ones, socodesignfinds the identity.find-identity ... | awkreads the imported identity’s SHA-1, so neither your Team ID nor your company name appears in the workflow, and a name mismatch like mine cannot happen.delete-keychainwithif: always()runs even after a failure. GitHub-hosted runners are discarded after each job anyway, so this matters most on self-hosted runners.
In the notarize step, --output-format json and jq give the job a status to check, so it fails on anything but Accepted instead of relying on notarytool’s exit code, which Apple does not document. The log is uploaded with every release. The man page documents the JSON option but not its id and status keys; if they ever change, the step fails loudly, which is the safe direction.
Push a tag to run it:
git tag v1.2.3
git push origin v1.2.3
Verify
On a Mac that has never seen your app (a fresh macOS virtual machine is ideal, since Gatekeeper caches what it has already checked), download the .dmg from the GitHub release with Safari so it gets the quarantine attribute. Then:
spctl --assess --type open --context context:primary-signature -v ~/Downloads/YourApp-v1.2.3-macos-universal.dmg
xcrun stapler validate ~/Downloads/YourApp-v1.2.3-macos-universal.dmg
/Users/<you>/Downloads/YourApp-v1.2.3-macos-universal.dmg: accepted
source=Notarized Developer ID
stapler validate exits with status 0 when the stapled ticket is present and valid (echo $? prints 0).
Open the disk image, drag the app to Applications, and open it. You should get only the standard prompt asking whether you are sure you want to open an app downloaded from the internet. For a real offline test, turn off the network after the download and before you open the disk image: with the stapled ticket it still opens. Finally, codesign -dv --verbose=4 /Applications/YourApp.app should show your company in the first Authority= line. Do not expect a stapled ticket on the copied app itself: in this layout the ticket is stapled to the disk image.
Troubleshooting
Developer ID Application: <Your Name> (<TEAM_ID>): no identity found: the name you passed is not the name on the certificate. Run security find-identity -v -p codesigning and copy the name exactly, or pass the 40-character hash. For an organization enrollment, the name is the legal entity, not you.
codesign asks for a password and rejects your Apple ID password: it wants the password of the keychain holding the private key, which on your own Mac is the login keychain and normally your macOS login password.
A leftover .cstemp file after an interrupted codesign run: delete it before you sign again. An interrupted attempt of mine left an orphaned .cstemp file that I had to delete.
notarytool history says In Progress long after the submission finished: ask about that submission directly with xcrun notarytool info <submission-id> or xcrun notarytool log <submission-id>. In my case history still said In Progress after 30 minutes while log returned "status": "Accepted".
A brand-new team’s submissions sit in In Progress for hours: an Apple DTS engineer says some uploads are held for in-depth analysis that can take a day or two, and that this eases as the service learns your app. In CI, the job’s timeout-minutes: 60 cancels the run before then; the submission keeps going at Apple, so check it later with notarytool info or raise the timeout for your first releases. If the status is instead statusCode: 7000 with Team is not yet configured for notarization, that is an account problem only Apple can fix. Contact Apple Developer Support.
Personal Information Exchange (.p12) is greyed out in Keychain Access: select the certificate together with its private key. If no key appears under the certificate, this Mac does not have it; export from the Mac where the certificate was created.
CI fails copying AppIcon.icns (or any packaging file): it exists on your Mac but is not in Git. git check-ignore -v packaging/AppIcon.icns shows the .gitignore rule that excludes it. Mine was ignored. Remove the rule, then commit the file.
The executable does not have the hardened runtime enabled.: an executable was signed without --options runtime. Check every executable in the bundle, nested helpers included. codesign -dv must show flags=0x10000(runtime).
The signature does not include a secure timestamp.: add --timestamp and make sure the machine can reach timestamp.apple.com. codesign -dvv shows Timestamp= when it worked.
The binary is not signed with a valid Developer ID certificate. or The signature of the binary is invalid. with a path inside your bundle: nested code is unsigned, signed with the wrong certificate, or the bundle changed after signing. Sign nested items first, the bundle last, and change nothing afterwards. codesign --verify --deep --strict --verbose=2 shows which item fails.
errSecInternalComponent in CI: codesign needed the private key and could not get it without a GUI. Usually the keychain is locked, the key’s access list does not include codesign, or the partition list was never set. Re-check the unlock-keychain, import -T /usr/bin/codesign and set-key-partition-list lines, and never run the signing step with sudo. If it comes with unable to build chain to self-signed root for signer, the Developer ID intermediate is missing: download Developer ID - G2 (and G1) from Apple’s certificate authority page and import them into the temporary keychain with security import <file>.cer -k "$KEYCHAIN_PATH".
401 Unauthorized from notarytool with an API key: an Individual key, or a key ID, issuer and .p8 that do not match. Use a Team key with --issuer.
Sources and further reading
- Creating distribution-signed code for macOS: identities, inside-out order,
--timestamp,-o runtime, and why not--deep. - Customizing the notarization workflow:
ditto,notarytool submitandlog, stapling limits, online ticket lookup, timing. - Resolving common notarization issues: the exact notary error messages and their fixes.
- Packaging Mac software for distribution: building and signing disk images, notarizing the outermost container.
- Hardened Runtime: what it restricts and the exception entitlements.
- TN3147: Migrating to the latest notarization tool:
notarytoolcredentials,info,logandhistory. - Creating API keys for App Store Connect API: Team versus Individual keys, and why Individual keys cannot notarize.
- TN2206: macOS Code Signing In Depth: verification output and signing order.
- Updates to runtime protection in macOS Sequoia: the removal of the Control-click override.
- Safely open apps on your Mac: what users see, and the Open Anyway steps.
- Resolving errSecInternalComponent errors during code signing: Apple DTS on keychains in SSH and CI sessions.
- The Care and Feeding of Developer ID: Apple DTS on backing up and protecting the identity.
- Installing an Apple certificate on macOS runners: GitHub’s temporary keychain recipe.
- GitHub Actions runner images: what
macos-latestcurrently points to. - Rust platform support: Apple Darwin: target tiers, minimum macOS versions and
MACOSX_DEPLOYMENT_TARGET. - Apple Developer Program enrollment: price and organization requirements.