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>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-21 12:57:51 -07:00
1 parent a9fec9ee27
commit 9898e56950
14 files changed
+3852 -2

No files matched your search

Generated
+64
View File
@@ -1651,6 +1651,9 @@ name = "deranged"
version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c"
dependencies = [
"serde_core",
]
[[package]]
name = "deunicode"
@@ -3215,6 +3218,8 @@ dependencies = [
"hyper",
"hyper-util",
"rustls",
"rustls-native-certs",
"rustls-platform-verifier",
"tokio",
"tokio-rustls",
"tower-service",
@@ -3610,6 +3615,34 @@ dependencies = [
"hybrid-array",
]
[[package]]
name = "instant-acme"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f05ad37c421b962354c358d347d4a6130151df9407978372d3ad7f0c8f71a64"
dependencies = [
"async-trait",
"base64 0.22.1",
"bytes",
"http",
"http-body",
"http-body-util",
"httpdate",
"hyper",
"hyper-rustls",
"hyper-util",
"rcgen",
"ring",
"rustls",
"rustls-pki-types",
"serde",
"serde_json",
"thiserror 2.0.21",
"time",
"tokio",
"x509-parser",
]
[[package]]
name = "ipnet"
version = "2.12.2"
@@ -4111,6 +4144,37 @@ dependencies = [
"zip",
]
[[package]]
name = "ledger-link"
version = "0.1.0"
dependencies = [
"async-trait",
"base64 0.22.1",
"bytes",
"futures",
"hickory-proto",
"http",
"http-body-util",
"instant-acme",
"ledger-store",
"rcgen",
"relay",
"ring",
"rustls",
"serde",
"serde_json",
"sha2 0.10.9",
"tempfile",
"thiserror 2.0.21",
"time",
"tokio",
"tokio-rustls",
"tokio-util",
"webpki-root-certs",
"x509-parser",
"zeroize",
]
[[package]]
name = "ledger-mcp"
version = "0.1.0"