Allow on-demand certs for the server's own infrastructure hosts#15
Merged
Conversation
The on-demand TLS ask endpoint refused the bare server hostname and the admin subdomain because neither is backed by a tunnel - but the wildcard cert covers *.host, not the host itself, so the server host reaches the on-demand path and broke the control-connection TLS handshake on a canary deploy. Always allow the server hostname and admin subdomain (mirroring the previous platform ask), plus any hosts listed under the new on_demand_tls.always_allow_hosts config, in addition to hosts with a live tunnel. Adds tests for each case and trims the controller doc-comment (full docs live in the SSL docs). Inert until a Caddyfile points its on-demand ask at the endpoint, so existing setups are unaffected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Follow-up to the on-demand TLS
askendpoint (/expose/can-issue-certificate, added in #14). On a canary deploy it refused the bare server hostname (ap-1.sharedwithexpose.com) and the admin subdomain, because neither is backed by a tunnel — but the wildcard certificate covers*.host, not the host itself, so the server host reaches the on-demand path. The refusal failed the control-connection TLS handshake (ECONNRESET), so clients could no longer connect.What
askhad. This fixes the canary regression.on_demand_tls.always_allow_hostsconfig for any additional non-tunnel hosts that should still obtain a certificate (e.g. a status page). Default empty.Safety
The endpoint stays inert until a Caddyfile points its on-demand
askat it, so merging changes nothing for existing setups. No expose-config switch is required to use the feature; activation lives entirely in Caddy.Tests
tests/Feature/Server(56 passing), incl. certificate cases: refuse-without-tunnel, allow-with-tunnel, allow-server-host, allow-admin-subdomain, allow-configured-host.