mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-30 02:04:54 +01:00
An app hosting a live session for other machines sent the session token in the clear over plain ws://. Such a host now serves TLS with an ephemeral self-signed Ed25519 certificate (DER written by hand with ring, no new crates), and its invite links pin the certificate's SHA-256 (`cert=`, URL-safe base64): figcraft://join?server=wss://…&cert=… and wss://…/?cert=… - tls: the shared session is a rustls::Connection (client or server), keeping the split reader/writer locking; `accept` answers a server handshake by the hello deadline; `handshake_pinned` uses a verifier that compares the end-entity certificate's SHA-256 in constant time and still checks the TLS 1.2/1.3 handshake signature, refusing any other certificate before the Hello with a clear reason. - invite: Endpoint::cert (None for Endpoint::plain), Endpoint::pinned; a malformed pin, one on ws://, or two that disagree is an error that never echoes the link. The pin stays out of the WebSocket request URL. An automation allowlist entry allows only its own pin. - host/hub: HostConfig::tls, Host::cert_sha256, Host::endpoint; the hub carries the server config to each connection. Hosting::serve (the server) is unchanged. - link: NetLink::host serves TLS for non-loopback binds without a join code. Join-code (short) shares stay plain ws://: a 20-symbol code has no room for the pin, and its joiners share the token with the link. - web: the browser refuses a pinned link with a clear reason. Tests: pinned join and edit sync both ways, a plain client against a TLS host, a host presenting another certificate (refused, not admitted), the request carrying neither token nor pin, link round trips and malformed cert= values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>