fix(gateway): persist mitmproxy CA on the host, not a named volume (#450)
The shared gateway self-generates a mitmproxy CA that every bottle installs to trust its TLS interception. It was persisted on a Docker named volume, which survives `docker rm` but is silently wiped by `docker volume prune` / `docker system prune --volumes` during routine host maintenance. When that happens the gateway mints a fresh CA on restart, and every already-running bottle fails the TLS handshake even after it re-resolves and reconnects to the moved gateway — a re-attachment blocker distinct from #443/#445. Move CA persistence to a host bind-mount under the app-data root (`bot_bottle_root()/gateway-ca`, via `host_gateway_ca_dir()`), mirroring how the shared DB and control-plane token already live on the host. Docker never prunes a path under the root, and it stays inspectable + rotatable from the host. mitmproxy already adopts an existing CA and generates one only on first run, so the bind-mount gives adopt-existing/generate-on-first-run for free. Add an explicit rollover path: `rotate_gateway_ca()` clears the persisted CA so the next start remints it, and `python -m bot_bottle.orchestrator.rotate_ca` wires that together with dropping the running gateway container (whose mitmproxy still holds the old CA in memory). Rotation stays an operator action — it doesn't auto-re-provision running bottles, which re-attach to pick up the new anchor. Scope: the Docker infra/gateway path (the "infra container" in the report). The macOS (`container`-only volume) and Firecracker (VM-attached ext4) backends persist the CA differently and are unaffected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -312,6 +312,35 @@ reaches over the RPC rather than a shared mount into the VM. WAL on the
|
||||
shared DB is therefore a deliberate, tested future change — not enabled ad
|
||||
hoc. `sqlite3` itself is stdlib, so "the host needs SQLite" is a non-cost.
|
||||
|
||||
### Gateway CA: host-resident, like the DB
|
||||
|
||||
The shared gateway bumps TLS with a self-generated mitmproxy CA, and **every
|
||||
bottle installs that CA** into its trust store to accept the bumped leaves. So
|
||||
the CA is durable per-host state with the same rule as the DB: it must outlive
|
||||
any single gateway container, or a restart mints a fresh CA that every
|
||||
already-running bottle distrusts — the TLS handshake then fails even after the
|
||||
bottle re-resolves and reconnects to the moved gateway (issue #450, a
|
||||
re-attachment blocker distinct from #443/#445).
|
||||
|
||||
The CA lives on the **host filesystem** at `bot_bottle_root()/gateway-ca`
|
||||
(`host_gateway_ca_dir()`), bind-mounted into the container at mitmproxy's
|
||||
confdir. This is deliberately a host bind-mount, **not a Docker named volume**:
|
||||
a named volume survives `docker rm` but is silently wiped by
|
||||
`docker volume prune` / `docker system prune --volumes` during routine host
|
||||
maintenance, which is exactly how the ephemeral-CA symptom shows up in
|
||||
practice. A path under the app-data root is never pruned by docker, and stays
|
||||
directly inspectable and rotatable from the host. mitmproxy reuses an existing
|
||||
CA and generates one only on first run, so the bind-mount alone gives
|
||||
"adopt-existing, generate-on-first-run" for free.
|
||||
|
||||
**Deliberate rollover** is the explicit inverse: `rotate_gateway_ca()` removes
|
||||
the persisted CA material so the next start remints it, and the
|
||||
`python -m bot_bottle.orchestrator.rotate_ca` one-shot wires that together with
|
||||
dropping the running gateway container (whose mitmproxy still holds the old CA
|
||||
in memory). Rotation does not auto-re-provision the new CA into running bottles
|
||||
— those re-attach to install the new anchor — so it is an operator action with
|
||||
a brief egress interruption, never an implicit one.
|
||||
|
||||
## Sequencing
|
||||
|
||||
Jump straight to the **virtualized** end state (not a host-daemon stepping
|
||||
|
||||
Reference in New Issue
Block a user