Install
Markdown
Ask AI
Share

How to Check a Downloaded Mac App Before You Open It

Verify a Mac download in Terminal: compare the SHA-256 with shasum, ask Gatekeeper with spctl, read the signer with codesign and check notarization.

Markdown
Ask AI
Share

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#

CheckCommandAnswers
Checksumshasum -a 256Is this the published file?
Gatekeeperspctl --assessWould macOS accept this app?
SignaturecodesignWho signed it, and was it changed since?
Ticketstapler validateIs the notarization ticket attached?

Step 1: compare the checksum#

Get the SHA-256 from the publisher’s own page, then run:

bash
cd ~/Downloads
echo "7ae3f9e6ddcc8b7a8689e636bfe28087a708765a4ae2889a42f8c2c724b30342  Levelrail_0.1.0_arm64.dmg" | shasum -a 256 -c

Keep the two spaces between the hash and the file name. A match prints:

output
Levelrail_0.1.0_arm64.dmg: OK

If 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:

bash
hdiutil attach -readonly -nobrowse ~/Downloads/Levelrail_0.1.0_arm64.dmg
spctl --assess --type execute -vv /Volumes/Levelrail/Levelrail.app

The output for this release:

output
/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#

bash
codesign --verify --deep --strict --verbose=2 /Volumes/Levelrail/Levelrail.app
codesign -dv --verbose=2 /Volumes/Levelrail/Levelrail.app

The output of the first command should include these two lines:

output
/Volumes/Levelrail/Levelrail.app: valid on disk
/Volumes/Levelrail/Levelrail.app: satisfies its Designated Requirement

The second prints details. These are the ones to read:

output
Identifier=com.levelrail.desktop
Authority=Developer ID Application: Gagan Deep Singh (CR6FQFMMSW)
Authority=Developer ID Certification Authority
Authority=Apple Root CA
TeamIdentifier=CR6FQFMMSW

The 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:

bash
codesign --test-requirement="=notarized" --verify --verbose /Volumes/Levelrail/Levelrail.app

Success includes the line explicit requirement satisfied.

Step 4: check the stapled ticket#

bash
xcrun stapler validate /Volumes/Levelrail/Levelrail.app

For 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:

bash
hdiutil detach /Volumes/Levelrail

If 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.

Next steps

Keep reading