You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tls: allow a certificate for names other than localhost (extra_sans, cert_file, key_file) #1719
Native TLS (tls.enabled: true) can only serve a certificate that is valid for localhost, 127.0.0.1 and ::1. A client that reaches mcpproxy by any other name (a Docker service name, a VM host name, a tailnet name, a Kubernetes service) cannot verify it. sbx and most MCP clients verify certificates, so for these setups native TLS is unusable and people put a reverse proxy in front just to change the certificate.
What the code does today
In internal/tlslocal/localca.go, EnsureServerTLSConfig:
It creates ca.pem / ca.key and localhost.pem / localhost.key in tls.certs_dir (default ~/.mcpproxy/certs) if they are missing.
The generated server certificate has DNSNames: ["localhost"] and IPAddresses: [127.0.0.1, ::1]. There is no setting to add to that list.
If localhost.pem and localhost.key already exist they are loaded as they are. So the only way to serve another name today is to leave a hand-made certificate under the file name localhost.pem in certs_dir, which is not documented and is easy to overwrite or lose.
TLSConfig has enabled, require_client_cert, certs_dir and hsts; nothing else.
Proposal
Smallest change first:
tls.extra_sans: a list of DNS names and IP addresses added to the generated server certificate. The certificate is regenerated, signed by the same local CA, when the list differs from what the existing certificate carries. mcpproxy trust-cert keeps working because the CA does not change.
tls.cert_file and tls.key_file: use a certificate the operator supplies (from a real CA, an internal CA, certbot, or a Kubernetes secret mount). Both or neither; a startup error that names the setting if only one is set or a file cannot be read. When set, nothing is generated.
Optionally tls.client_ca_file for require_client_cert, since with an external server certificate the client CA is otherwise still the generated local ca.pem.
Either 1 or 2 alone solves the hostname problem. 2 is the one that fits container and Kubernetes secret mounts, and it composes with MCPPROXY_API_KEY_FILE (#1706).
Not asking for
ACME, automatic renewal, or any change to the default behaviour: with none of the new settings, startup is byte-for-byte what it is now.
I can send a PR for 1, 2 or both. Which would you take, and should the key file follow the same read rules as the secret file reader (absolute path, regular file, size cap)?
Activity
feat(tls): serve a certificate for names other than localhost (extra_…