Repository navigation
Mac relay
tools/macoun-relay is a small HTTPS server that runs on a Mac and answers three requests:
| Endpoint | Auth | Returns |
|---|---|---|
POST /validation-data |
bearer token | NAC validation data, produced on the Mac with AAAbsintheContext
|
GET /anisette |
bearer token | Apple anisette headers, produced with AOSKit
|
GET /health |
none | JSON status, no secrets |
Apple requires both kinds of data and only accepts them from genuine Apple hardware and software. The bridge asks for them when it registers, refreshes the Apple ID token, or talks to iCloud. Message traffic never passes through the relay.
The relay code is AGPL-3.0 and comes from corten-matrix's earlier relay (commit e2adc79d92), with an anisette endpoint, a JSON health endpoint and a size-capped log added.
- macOS 13 to 15. macOS 26 is untested. Do not use macOS 27: anisette through AOSKit is reported broken there.
- Intel is verified. Apple Silicon is expected to work.
- Signed in to iCloud with the Apple ID the bridge uses.
- Always on: no system sleep, restart after power loss.
- A logged-in GUI session. The relay is a per-user LaunchAgent and AOSKit needs an Aqua session. Surviving an unattended reboot therefore needs auto-login, which needs FileVault off. Decide whether that trade-off is acceptable for where the Mac lives.
- macOS updates installed by hand, with a check afterwards, because an update can change the private frameworks.
Bind the relay to a private interface only (the -addr argument in the LaunchAgent). A Tailscale or WireGuard address is the usual choice. Never expose it on the LAN or the internet: anyone who can reach it and has the token can obtain data that vouches for your Mac.
The bridge pins the relay's certificate by fingerprint and checks the pin with an unauthenticated /health request before it sends the token anywhere.
| Event | How often | If the Mac is away |
|---|---|---|
| Bridge start | Every start | The CloudKit bootstrap retries; on an install that has synced before, messages flow after 3 failed attempts |
| Apple ID token refresh | About 7 times a day | Retried; iCloud features degrade after about a day |
| IDS re-registration | Every 45 days, started 7 days early | Retried with backoff capped at 30 minutes |
| Login | When you log in | Login cannot complete |
A reboot or a few hours of downtime does not interrupt messaging. More detail in overview.md.
# on the Mac
launchctl print gui/$(id -u)/dev.macoun.relay | grep -E 'state|pid'
tail <relay-dir>/logs/relay.log
# from the bridge host
curl -sk --pinnedpubkey 'sha256//<public key pin>' https://<mac-ip>:5001/health/health answers 200 with "ok": true when both NAC and anisette work, and 503 with an explanation when they do not.
Stop the agent, delete token and relay-info.json from the relay's state directory, start the agent, and update MACOUN_NAC_RELAY_TOKEN on the bridge. Deleting cert.pem and key.pem makes a new certificate, so MACOUN_NAC_RELAY_CERT_FP changes too.
Rebuild with go build, then launchctl kickstart -k gui/$(id -u)/dev.macoun.relay. After any macOS update, check /health.
The bridge only needs a service that speaks the provider contract. Validation data and anisette can come from different providers.