Commit Graph
2 Commits
Author SHA1 Message Date
swaitsandClaude Fable 5.2 b90df7158a fix(link): the app believes only public authorities, only their hosts, and only while a certificate lasts
The review of P15 B3 found the relay could steer three things it must not.

- A certificate is now checked against the public roots the program
  ships, for the app's wildcard, when it is issued and every time it is
  read from disk; a lifetime over 100 days is refused (no public
  authority issues one), and the renewal is planned no later than two
  thirds of the life or 60 days. A kept certificate that fails is
  ignored and ordered again. Only a test builds a CertTrust of its own
  roots.
- The ACME client sends a request only to a directory on a host compiled
  into the app (Let's Encrypt production and staging, Google Trust
  Services, ZeroSSL, Buypass, SSL.com): the relay still picks which and
  in what order, but cannot name a new host. A kept account is used only
  if its directory is on the list too. http is a direct dependency now
  (it was a dev-dependency, and already in the tree): the host is read
  with the parser the ACME library uses.
- The resolver refuses a certificate at its end, sleeps stop at it, and
  the state stops saying "Connected" when it has ended.
- The certificate work waits for the line, so it is for the name the
  relay accepted (a first claim that finds the name taken picks another);
  web.rs starts the door only once the name is settled.
- A line that held under 60 s does not reset the backoff; one that held
  is redialled after 0 to 30 s, so a relay restart is not met by every
  app in the same second.
- What the relay and the authority say is shown as a short quoted detail
  with control and invisible characters removed, in the app's own words.
- The kept address is read once, not from the key file every frame; the
  folder is synced after a private file is renamed into place.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 14:59:57 -07:00
swaitsandClaude Fable 5.2 9898e56950 feat(link): the app's side of the relay: identity, line, TLS at the app, certificates (P15 B3)
The app keeps one durable address https://<secret>.<four-words>.wanderbooks.link:
an Ed25519 key, a four-word name the app picks, and a 32-character base-36 secret
label (about 165 bits), all in private (0600 / owner-only) files in the data
root's link/ folder. One name per installation, as plan section 5 says; each
company is a path under it.

The line (yamux over TLS 1.3, the relay crate's own client) runs in the app's own
process, not in the books server child: a window that dies takes its sockets with
it, so the line can never keep a door open for books that closed. It reconnects
with full-jitter backoff, pings every 30 s (the relay drops a line silent for
180 s), re-dials at once after a wall-clock jump (a sleep), and says in words
what is wrong: no internet, the relay down, a busy relay, a wrong clock, a name
the relay lost.

TLS ends in the app with its own certificate (rustls, ALPN h2 and http/1.1),
served only for the app's exact host name, then the plain stream goes to the
remote door on 127.0.0.1 after the door's per-start secret and the relay's PROXY
header. The private keys are never sent to the relay.

Certificates are ordered by ACME DNS-01 (instant-acme, behind an Issuer trait so
tests use an in-process authority) for the wildcard under the app's name, from
the relay's authority list in its order (a not-usable one is skipped, a failing
one falls to the next), stored, reused across restarts, and renewed at the time
the authority's renewal information suggests, else two thirds through the life.

New dependencies: instant-acme 0.8 (Apache-2.0; ring, hyper-rustls, time and
x509-parser features, no aws-lc-rs), x509-parser 0.18 and webpki-root-certs 1
(already in the tree), time and async-trait for tests.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 12:57:51 -07:00