Hi everyone,
Since macOS 12.3+ removed built-in Python, I try to bundle the official Python installer package (.pkg) in our Mac Application (.app). Therefore the user can install Python directly in the application to make one of our app functions correctly.
However, this application cannot be opened because macOS cannot verify that this app is free from malware. This issue happened on macOS 12.4, but it can be opened without any error messages on macOS 10.14.6.
When bundling the package, I did re-sign it using our developer ID certificate, And the app also passes the notarization process. Then I checked the following utilities on macOS 12.4 and all of them are correct. Please help me to solve this issue. Thank you very much.
Checking the Gatekeeper:
spctl -a -t exec -vvv --ignore-cache Spark.app
Spark.app: accepted
source=Notarized Developer ID
origin=Developer ID Application: *** Inc (SKLFZ4533Y)
Checking the signature of application:
codesign -vvv --check-notarization --deep Spark.app
--prepared:/Users/oz-chc/Downloads/Spark.app/Contents/Helpers/python.pkg
--validated:/Users/oz-chc/Downloads/Spark.app/Contents/Helpers/python.pkg
Spark.app: valid on disk
Spark.app: satisfies its Designated Requirement
Checking the signature of Python package after re-sign and bundle it. (I marked the fingerprint)
pkgutil --check-signature Spark.app/Contents/Helpers/python.pkg
Package "python.pkg":
Status: signed by a developer certificate issued by Apple for distribution
Notarization: trusted by the Apple notary service
Signed with a trusted timestamp on: 2022-08-25 03:07:00 +0000
Certificate Chain:
1. Developer ID Installer: *** Inc (SKLFZ4533Y)
Expires: 2024-10-25 04:12:29 +0000
SHA256 Fingerprint:
******
------------------------------------------------------------------------
2. Developer ID Certification Authority
Expires: 2027-02-01 22:12:15 +0000
SHA256 Fingerprint:
******
------------------------------------------------------------------------
3. Apple Root CA
Expires: 2035-02-09 21:40:36 +0000
SHA256 Fingerprint:
******
Thanks for Eskimo's professional help via the support ticket, this problem got fixed. 😃 Here are the root cause and solution. Hope this information can help people who are bothered by similar issue.
The real problem is that I placed the Python installer package (.pkg) file in Contents/Helpers of the app bundle, which is a location reserved for code rather than data. So code signing tool has signed it in a wrong way, which causing Gatekeeper think the app's signing is wrong and refused the app to be opened.
The fix is simple. I just relocate the inappropriate items in Contents/Helpers, specifically place the installer package along with other data files in Contents/Resources. Rebuild the app. Done! The new app is now able to pass Gatekeeper checking on macOS 12.3, 12.4, and even 12.5.
Reference documents in detail:
If you put content in the wrong location, you may encounter hard-to-debug code signing and distribution problems.