Four Terminal checks tell you whether a Mac download is the file the publisher released, who signed it and whether Apple notarized it. None of them runs the app.
The examples use the Levelrail for Mac 0.1.0 disk image. Swap in your own file names.
The checks at a glance#
| Check | Command | Answers |
|---|---|---|
| Checksum | shasum -a 256 | Is this the published file? |
| Gatekeeper | spctl --assess | Would macOS accept this app? |
| Signature | codesign | Who signed it, and was it changed since? |
| Ticket | stapler validate | Is the notarization ticket attached? |
Step 1: compare the checksum#
Get the SHA-256 from the publisher’s own page, then run:
cd ~/Downloads
echo "7ae3f9e6ddcc8b7a8689e636bfe28087a708765a4ae2889a42f8c2c724b30342 Levelrail_0.1.0_arm64.dmg" | shasum -a 256 -cKeep the two spaces between the hash and the file name. A match prints:
Levelrail_0.1.0_arm64.dmg: OKIf a release ships a .sha256 file, as this one does, save it next to the download and run shasum -a 256 -c Levelrail_0.1.0_arm64.dmg.sha256.
A mismatch means stop. Delete the file and download it again from the official page.
Step 2: mount the image and ask Gatekeeper#
Mounting a disk image does not start the app inside it. Double click the file, or mount it read-only:
hdiutil attach -readonly -nobrowse ~/Downloads/Levelrail_0.1.0_arm64.dmg
spctl --assess --type execute -vv /Volumes/Levelrail/Levelrail.appThe output for this release:
/Volumes/Levelrail/Levelrail.app: accepted
source=Notarized Developer ID
origin=Developer ID Application: Gagan Deep Singh (CR6FQFMMSW)Read all three lines. accepted is the verdict, source says it is notarized, and origin names the signer. Check that the signer is who you expect.
Run this check on the app. For Levelrail 0.1.0 the signature and notarization are on the app, and the .dmg is its container, so assessing the image itself reports no usable signature. The checksum in step 1 is what covers the image.
Step 3: verify the signature#
codesign --verify --deep --strict --verbose=2 /Volumes/Levelrail/Levelrail.app
codesign -dv --verbose=2 /Volumes/Levelrail/Levelrail.appThe output of the first command should include these two lines:
/Volumes/Levelrail/Levelrail.app: valid on disk
/Volumes/Levelrail/Levelrail.app: satisfies its Designated RequirementThe second prints details. These are the ones to read:
Identifier=com.levelrail.desktop
Authority=Developer ID Application: Gagan Deep Singh (CR6FQFMMSW)
Authority=Developer ID Certification Authority
Authority=Apple Root CA
TeamIdentifier=CR6FQFMMSWThe chain should end at Apple Root CA. Note the team identifier: a later version of the same app should normally carry the same one.
You can also ask codesign to require notarization:
codesign --test-requirement="=notarized" --verify --verbose /Volumes/Levelrail/Levelrail.appSuccess includes the line explicit requirement satisfied.
Step 4: check the stapled ticket#
xcrun stapler validate /Volumes/Levelrail/Levelrail.appFor this release it ends with The validate action worked!.
A stapled ticket lets Gatekeeper confirm notarization without a network connection. Software can be notarized without one, in which case Apple says Gatekeeper finds the ticket online. So read a missing ticket together with the spctl result.
When you are done, eject the image:
hdiutil detach /Volumes/LevelrailIf a check fails#
Treat a failure as information. If spctl says rejected for an app, or the signer is not the one you expect, do not open it.
Apple documents an Open Anyway button under System Settings, Privacy & Security, for apps you are certain come from a trustworthy source. Read Apple’s guidance first, and be wary of any download page that tells you to strip security attributes in Terminal.
What to do next#
Copy the app to Applications once the checks pass. The Levelrail download page shows the checksum and the requirements. For server binaries and container images, see verifying a Levelrail release with checksums and cosign, or the install page.
Frequently asked questions #
Does a matching SHA-256 mean the app is safe?
No. It means your file is the same as the one the publisher hashed. Use it together with the signature and notarization checks.
What does notarized mean?
Apple says that for a notarized app, it checked the software for malicious content and none was detected. It is not a review of what the app does.
Do I need Xcode for these checks?
shasum, spctl, codesign and hdiutil come with macOS. The stapler tool is part of Apple's developer tools.