Add ACME TLS-ALPN-01 challenge with an ALPN gate on 443 - #128
Merged
Conversation
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.
Adds the ACME TLS-ALPN-01 challenge (RFC 8737): Sōzune can now obtain Let's Encrypt certificates with neither port 80 (HTTP-01) nor DNS API credentials (DNS-01). The validation happens over the TLS handshake on 443 itself. Built on cheti's new
TlsAlpn01Solver.Usage
An entrypoint (or Docker label) points at the resolver:
sozune.http.app.acme.resolver=edge.How it works
Answering the challenge means intercepting the handshake on 443, which the HTTPS worker can't do alone. So — only when a
tls-alpn-01resolver is configured — Sōzune fronts 443 with an ALPN-aware gate:acme-tls/1handshakes go to a local rustls responder that presents cheti's challenge certificate;The real client IP is preserved: the gate prepends a PROXY-v2 header the worker consumes (
with_expect_proxy), so client-IP allow-lists, access logs and metrics stay accurate. Without atls-alpn-01resolver, none of this happens — 443 stays a direct HTTPS listener, byte-for-byte the old path.Three commits
Resolver::TlsAlpn01, config). Safe in isolation — nothing routes to it yet.acme-tls/1to the responder. This is the part that touches the production HTTPS path.Verified end-to-end
A Pebble-based harness (
tests/e2e/acme/run-alpn.sh) issues a real certificate over a real TLS-ALPN-01 challenge, hermetically, and asserts normal HTTPS still flows through the gate and reaches the backend.Hardening
The 443 gate is the riskiest code here — it fronts all HTTPS traffic — so it went through two Codex review rounds, nine issues fixed:
with_expect_proxy, destination taken fromlocal_addr();The hand-rolled ClientHello ALPN parse has unit tests for each case (fragmentation, trailing-byte rejection, non-TLS, truncation, PROXY-v2 encoding).
Limitation
Wildcards are not supported (a TLS-ALPN-01 validator connects to a concrete name). Use DNS-01 for
*.example.com.