WS-I: native TLS (optional, default off) with SIGHUP cert reload

server.tls.{enabled,cert_file,key_file}; rustls (ring, explicit provider) via
tokio-rustls + hyper-util; https:// MCP origins when enabled; non-loopback
plain-HTTP startup warning; tests/tls.rs; README TLS section.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ariandClaude Sonnet 5.5 committed 2026-10-16 07:10:14 -04:00
1 parent c83a5fa1ac
commit c5972b762f
11 files changed
+835 -15

No files matched your search

+15 -2
View File
@@ -412,7 +412,8 @@ fn allowed_hosts(state: &AppState) -> Vec<String> {
}
/// Allowed `Origin` values: loopback origins and `server.bind` on the
/// configured port, plus configured extras.
/// configured port, plus configured extras. The scheme is `https` when
/// `server.tls.enabled`, otherwise `http`.
fn allowed_origins(state: &AppState) -> Vec<String> {
let s = &state.config.server;
let mut hosts = vec![
@@ -423,9 +424,10 @@ fn allowed_origins(state: &AppState) -> Vec<String> {
if !s.bind.is_unspecified() {
hosts.push(authority(s.bind));
}
let scheme = if s.tls.enabled { "https" } else { "http" };
let mut v: Vec<String> = hosts
.into_iter()
.map(|h| format!("http://{h}:{}", s.port))
.map(|h| format!("{scheme}://{h}:{}", s.port))
.collect();
v.extend(s.allowed_origins.iter().cloned());
v
@@ -783,6 +785,17 @@ mod tests {
let _svc = service(st);
}
#[test]
fn tls_switches_default_origins_to_https() {
let mut cfg = Config::default();
cfg.server.tls.enabled = true;
let st = fake_state(cfg);
let o = allowed_origins(&st);
assert!(o.contains(&"https://localhost:9109".to_string()));
assert!(o.contains(&"https://127.0.0.1:9109".to_string()));
assert!(!o.iter().any(|x| x.starts_with("http://")));
}
#[test]
fn ipv6_non_loopback_bind_allowlists() {
let mut cfg = Config::default();