# Encrypt Data in Motion Findings from issue #790. The ask: a compromised router (or anyone on the local LAN) shouldn't be able to read plaintext traffic between the Flutter client and the butler's HTTP API, even though the data never leaves the house. Explicitly **not** about encrypting data at rest — moving a drive to a new device needs to keep working without a decryption step. ## Threat model A compromised router, or anyone else on the LAN, doing passive MITM on plain HTTP traffic between the app and the butler's API. Today's common path is bare HTTP on port 80 for local access — TLS termination only exists in some deployments, not universally. ## The cert problem Real TLS locally means either a self-signed cert (which browsers/Flutter reject without an explicit trust exception) or a real domain + Let's Encrypt, which pulls in the Tailscale/tunnel work from `Spikes/Remote-Access.md`. **The two clients behave differently here:** - **Flutter native (iOS/Android/desktop)** can use a custom `SecurityContext` or certificate pinning silently — no user-visible warning, fully transparent. - **Web client** hits the browser's normal cert-trust UI: a self-signed cert triggers a one-time warning. Judged acceptable — approve once, then it's silent on later visits. ## Where TLS termination happens — confirmed: Option B shipped **Option A — nginx reverse proxy in front of Gin.** nginx generates and rotates a self-signed cert on first run; Gin stays HTTP-only internally. Not what was built. **Option B — Gin terminates TLS directly**, via `router.RunTLS()`. The server generates its own self-signed cert on startup if none exists. **This is what shipped**, confirmed against the codebase (2026-08-25): `pkg/util/tlsutil/` handles the self-signed cert on the backend, `serverutil.ServingTLS()` is a runtime flag the rest of the server checks, and the Flutter side has matching local-trust handling (`lib/services/local_trust.dart`, `lib/services/local_trust_overrides_io.dart`) for accepting that self-signed cert per the native-vs-web split described above. `pkg/util/remoteutil/remoteutil.go`'s tsnet proxy also reads `ServingTLS()` to decide whether to speak HTTPS or HTTP to the local server on the loopback hop. ## Tailnet traffic is a separate case Once traffic is routed through Headscale/tsnet (see `Spikes/Remote-Access.md`), WireGuard already encrypts it at the network layer. TLS on top of that is optional defense-in-depth, not required to close the threat model this ticket describes — that threat model is specifically local-network traffic that never touches the tailnet. ## Status Shipped, confirmed above — no longer an open design question. No implementation ticket was tracked for it separately from #790 itself; the work landed without an explicit follow-up ticket reference, which is why this page originally flagged it as unconfirmed.