I have an application (built with Qt / QML) that I am trying to sign and notarize for Ad hoc distribution outside the App Store (it's for internal company use). Apple confirms that my software has been notarized, and I then staple my .app - but Gatekeeper still stops the application from running and alerts users:
App Name can’t be opened because Apple cannot check it for malicious software.
What am I doing wrong?.
Here are the steps that I am following:
Ran QMake / Build in Qt Creator.
Modified the CFBundleIdentifier key in the generated Info.plist file to be com.myCompanyName.appName instead of com.yourcompany.appName as generated by Qt.
cd
to my build dir.Ran macdeployqt:
/Users/<user>/Qt/5.13.0/clang_64/bin/macdeployqt <appName>.app -qmldir=<project source code dir>
.Code Sign:
codesign --deep -f -s "Developer ID Application: <company name> (<team id>)" --options "runtime" "<appName>.app/"
(Where the developer id application is the name as it appears in KeychainAccess).Verified that the signature:
codesign -dv --verbose=4 <appName>.app
Returns:`Executable=<build dir>/<app name>.app/Contents/MacOS/<app name> Identifier=com.<company name>.<app name> Format=app bundle with Mach-O thin (x86_64) CodeDirectory v=20200 size=53750 flags=0x10000(runtime) hashes=1674+3 location=embedded Library validation warning=OS X SDK version before 10.9 does not support Library Validation VersionPlatform=1 VersionMin=658432 VersionSDK=0 Hash type=sha256 size=32 CandidateCDHash sha256=************************************* CandidateCDHashFull sha256=************************************* Hash choices=sha256 CMSDigest=************************************* CMSDigestType=2 Page size=4096 CDHash=************************************* Signature size=8990 Authority=Developer ID Application: <my company name> (<my team ID>) Authority=Developer ID Certification Authority Authority=Apple Root CA Timestamp=May 27, 2020 at 2:35:38 PM Info.plist entries=10 TeamIdentifier=V7L2LD4Q9S Sealed Resources version=2 rules=13 files=1198 Internal requirements count=1 size=184
Or if I look at a (chosen at random) executable from the Qt framework inside the app bundle:
codesign -dv --verbose=4 <appName>.app/Contents/Frameworks/QtCore.framework/Versions/5/QtCore
Returns:Executable=<build dir>/<app name>.app/Contents/Frameworks/QtCore.framework/Versions/5/QtCore Identifier=org.qt-project.QtCore Format=bundle with Mach-O thin (x86_64) CodeDirectory v=20500 size=49057 flags=0x10000(runtime) hashes=1526+3 location=embedded VersionPlatform=1 VersionMin=658432 VersionSDK=658944 Hash type=sha256 size=32 CandidateCDHash sha256=************************************* CandidateCDHashFull sha256=************************************* Hash choices=sha256 CMSDigest=************************************* CMSDigestType=2 Page size=4096 CDHash=************************************* Signature size=8990 Authority=Developer ID Application: <my company name> (<my team ID>) Authority=Developer ID Certification Authority Authority=Apple Root CA Timestamp=May 27, 2020 at 2:35:37 PM Info.plist entries=8 TeamIdentifier=V7L2LD4Q9S Runtime Version=10.14.0 Sealed Resources version=2 rules=13 files=1 Internal requirements count=1 size=184
zip:
ditto -ck --rsrc --sequesterRsrc "<appName>.app" "<appName>.zip"
Upload for notarization:
xcrun altool --notarize-app -t osx -f <appName>.zip --primary-bundle-id="com.<my company name>.<appName>" -u "<develpper ID @ company name> -p "<app specific password>"
Receive an email that "Your Mac software was successfully notarized."
Staple:
xcrun stapler staple "<appName>.app"
Returns:The staple and validate action worked!
Distribute:
- Create a blank sparse bundle disk image.
- Copy the appName.app bundle to it (along with a shortcut to /Applications).
- Convert to read only.
- Distribute to users.
If I look in Console.app - I can see in the logs that the app is being denied to open:
default 15:10:56.549137-0400 runningboardd Invalidating assertion 294-139-3156 (target:executable<<appName>(501)>) from originator 139
default 15:11:01.061942-0400 runningboardd [executable<<appName>(501)>:4893] Death sentinel fired!
There is nothing in the console with XprotectService
as this SO answer suggests.
If I try to use spctl to check the signature, it fails:
spctl -v -a -t open --context context:primary-signature <appName>.app
Returns:
opal.app: rejected
source=Unnotarized Developer ID
spctl -a -t exec -vv <appName>.app produces
Returns:
<appName>.app: rejected
source=Unnotarized Developer ID
origin=Developer ID Application: <my company name> (<team ID>)
produces: invalid API object reference
However, if I use stapler to validate the app, it passes:
stapler validate <appName>.app
Returns:
Processing: /<build dir>/<appName>.app
The validate action worked!
About my environment:
MacOS 10.15.3
Qt 5.13
Xcode 11.4