I was reading through this post:
https://developer.apple.com/forums/thread/718583
I've been able to reproduce this behavior by double-clicking a DMG in the Finder while the Mac is Offline. I checked the Notarization status of the app via spctl and it shows "Notarized Developer ID". So sure enough, Quinn's comment about Gatekeeper "ingesting" the notarization ticket stapled to the DMG and automatically applying it to the app inside is 100% spot-on.
However, I can't seem to get the same behavior to happen when mounting the DMG via hdiutil in Terminal. While Offline, I do a:
hdiutil attach /path/to/my/dmg.dmg
and then
spctl -a -t exec -vvv /Volumes/path/to/my/mounted/dmg/myapp.app
After the spctl I'm seeing
/Volumes/path/to/my/mounted/dmg/myapp.app: rejected
source=Unnotarized Developer ID
origin=Developer ID Application: My Developer Creds (XXXXXXXXXX)
Is there a way to get Gatekeeper to "ingest" the notarization ticket stapled to the DMG when using hdiutil while Offline?
Note 1: If I use hdiutil while online, everything works as expected. Note 2: I'm testing all this via a VM of macOS 12.7.1, if that makes any difference.
Thanks!
Yes, using "open" works
Yeah, that’s what I thought.
For Gatekeeper to ingest your ticket it must evaluate your product. When you run open
, it opens the disk image using NSWorkspace
which does a basic Gatekeeper check on it, which triggers that ingestion. This doesn’t happen when you mount it with hdiutil
.
From there we copy the app inside using
NSFileManager
.
If it’s an app you could avoid this problem by:
-
Siging your app.
-
Notarising your app.
-
Stapling to your app.
-
Wrapping it in a disk image.
-
Signing, notarising, and stapling your disk image, or not, as you see fit.
When the user runs your app for the first time, Gatekeeper which ingest the stapled ticket from there.
While I generally recommend that you sign and notarise your disk image, it’s not an absolute requirement [1].
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] Exception on some very early releases of… bah… I can’t remember, perhaps 10.15.