Skip to content

feat(hub): load main listener TLS from a certificate directory (--tls-dir)#77

Merged
gmpassos merged 1 commit into
masterfrom
web-client-browser-transport
Jun 28, 2026
Merged

feat(hub): load main listener TLS from a certificate directory (--tls-dir)#77
gmpassos merged 1 commit into
masterfrom
web-client-browser-transport

Conversation

@gmpassos

Copy link
Copy Markdown
Contributor

Summary

Adds --tls-dir to hub start / service install hub: the main wss listener can load its certificate from a directory holding fullchain.pem + privkey.pem (the Let's Encrypt layout), as a mutually-exclusive alternative to --cert/--key.

On renewal the Hub rebinds the listener on the same port (shared: true) with the freshly-loaded context, so the new certificate is served without a restart — established connections drain on the old listener while new ones land on the renewed cert.

When --tls-dir is set it also drives sensible tunnel defaults:

  • --tunnel-tls-dir defaults to the same directory (secure tunnels reuse the cert, hot-reloaded the same way).
  • --tunnel-public-host defaults to the certificate's DNS name (its SAN, falling back to the subject CN). This derivation applies in --cert/--key mode too.

Changes

  • Generalize TunnelTlsSource → reusable PemTlsSource (adds a log label), used for both the main listener and tunnel ports.
  • New CertificateNames.primaryDnsName — derives the public host from the leaf cert's SAN/CN (hand-rolled DER walk, in the existing spki.dart style).
  • HubConfig: nullable securityContext + tlsDirectory/tlsReloadInterval (asserts exactly one TLS source); OmnyShellHub rebinds on reload.
  • WsServerEndpoint.bind gains a shared flag for gap-free rebind.
  • README + CLI help updated for --tls-dir and the derived tunnel defaults.

Tests

  • New certificate_names unit test; renamed pem_tls_source reload tests.
  • CLI dry-run/validation tests (rendering, mutual exclusion, missing pems).
  • Integration test covering serve-over-wss-from-directory and the full renewal → rebind → reconnect cycle.
  • Full suite: 478 passing; dart analyze clean; dart format applied.

🤖 Generated with Claude Code

…-dir)

Add `--tls-dir` to `hub start`/`service install hub`: load the main wss
listener certificate from a directory holding fullchain.pem + privkey.pem
(Let's Encrypt layout) as a mutually-exclusive alternative to --cert/--key.
On renewal the Hub rebinds the listener (shared port) with the fresh
context so the new cert is served without a restart, draining existing
connections on the old listener.

When --tls-dir is set, --tunnel-tls-dir defaults to the same directory and
--tunnel-public-host defaults to the certificate's DNS name (SAN, falling
back to the subject CN).

- Generalize TunnelTlsSource -> reusable PemTlsSource (adds a log label),
  used for both the main listener and tunnel ports.
- Add CertificateNames.primaryDnsName to derive the public host from the
  leaf certificate's SAN/CN.
- HubConfig: nullable securityContext + tlsDirectory/tlsReloadInterval
  (exactly one TLS source); OmnyShellHub rebinds on reload.
- WsServerEndpoint.bind gains a `shared` flag for gap-free rebind.
- Tests: certificate_names, renamed pem_tls_source, CLI dry-run/validation,
  and an integration test covering serve + renewal->rebind->reconnect.
- README + CLI help updated for --tls-dir and the derived tunnel defaults.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gmpassos gmpassos merged commit be0d139 into master Jun 28, 2026
5 checks passed
@gmpassos gmpassos deleted the web-client-browser-transport branch June 28, 2026 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant