Documentation
¶
Overview ¶
Command machocmp checks that a signed macOS binary (or app bundle) made elsewhere contains exactly the code this repository builds, and nothing but an Apple code signature on top of it.
The release's macOS files are built, signed and notarized in another repository, where the Apple credentials live (see .github/workflows/release.yml). Go builds are reproducible: the same source, Go version and flags give the same bytes on any host. So the release workflow rebuilds the unsigned binaries from the tagged commit and runs this command, which accepts a signed slice only if
- every byte before the code signature equals the rebuilt slice, apart from the fields codesign rewrites: the LC_CODE_SIGNATURE load command (and the header's command count and size it changes), and the size of the __LINKEDIT segment that holds the signature;
- nothing follows the signature (but what the rebuild had there);
- the signature's code directories cover exactly that code, their page hashes match it, it carries no entitlements, and (when asked) the hardened runtime flag, the signing identifier and the Apple team ID are the expected ones.
Whether the signature itself is valid (the certificate chain to Apple and the notarization) is checked by codesign, spctl and stapler on a Mac; this command makes sure that what is signed is our code.
Usage:
machocmp [flags] SIGNED REF [REF...]
SIGNED is a universal or thin Mach-O; each REF a thin, unsigned (or
ad-hoc signed) rebuild, one per architecture of SIGNED.
machocmp [flags] -app SIGNED.app REF.app
every file of the rebuilt bundle must be in the signed one with the
same bytes, the executables under Contents/MacOS compared as above;
the signed bundle may add only its signature files.
machocmp -same DIR1 DIR2
the two trees hold the same files with the same bytes (no symlinks).
Flags: -team ID (Apple team identifier), -id IDENTIFIER (signing identifier), -runtime (require the hardened runtime).