Skip to content

feat(acme): add acme-dns (DNS-01) challenge support - #4

Merged
debiansid merged 3 commits into
devfrom
feat/acme-dns
Nov 17, 2026
Merged

debiansid merged 3 commits into
devfrom
feat/acme-dns

Conversation

@debiansid

Copy link
Copy Markdown

Summary

Adds acme-dns (DNS-01 challenge) support to shoes, matching sing-box's configuration schema (server_url, username, password, subdomain, and optional propagation_delay) and building natively onto existing hyper 1.0 and rustls infrastructure without adding external dependencies.

Key Changes

  • Configuration & Validation (src/certificates/mod.rs, src/certificates/tests.rs):
    • Added ChallengeConfig::AcmeDns (alias acmedns).
    • Added validation enforcing HTTPS/numeric-loopback URL, non-empty credentials/subdomain without newlines, and propagation_delay <= 3600.
  • ACME-DNS Client & ACME Integration (src/certificates/acme.rs):
    • Extracted shared TCP/TLS stream connector connect_stream.
    • Implemented update_acme_dns to perform authenticated HTTP/1.1 POST /update requests with X-Api-User, X-Api-Key, and JSON payload {"subdomain": "...", "txt": "..."}.
    • Wired ChallengeType::Dns01 in prepare_challenges, posting the TXT challenge value via authorization.dns_value(), applying propagation_delay, and setting the challenge ready.
  • Tests (src/certificates/acme_tests.rs, src/certificates/tests.rs):
    • Added positive and negative config validation tests.
    • Implemented loopback MockAcmeDns server.
    • Added unit tests for update_acme_dns (success, 401 unauthorized, 500 error, URL normalization).
    • Extended ACME CA test fixture to support dns-01 challenge verification.
    • Added end-to-end issuance and resumption roundtrip test acme_dns_issuance_roundtrip.

Verification

  • cargo check: 0 warnings, 0 errors
  • cargo test --lib certificates::acme::tests::acme_dns: 2 passed, 0 failed
  • cargo test --lib certificates::: 52 passed, 0 failed, 1 ignored (root-only test)
  • git diff --check: clean

debiansid and others added 3 commits November 17, 2026 22:09
- Add AcmeDns variant to ChallengeConfig supporting server_url, username, password, subdomain, and optional propagation_delay (alias acmedns).
- Implement native update_acme_dns client over hyper and rustls to publish DNS TXT records to acme-dns without external dependencies.
- Wire DNS-01 challenge completion in ACME scheduler.
- Add negative configuration validation, client unit tests, mock acme-dns server, and full ACME issuance roundtrip tests.
- Publish every TXT value first, then wait propagation_delay once
  (capped at the order deadline) before marking challenges ready, so
  N domains no longer cost N waits. Cap propagation_delay at 300 s,
  inside the 600 s order timeout.
- Reject more than 2 domains per source: acme-dns keeps only the 2
  newest TXT values per subdomain.
- Talk to acme-dns with the default web PKI roots instead of the
  ACME ca_cert roots.
- Store the password as a redacted Secret.
- Report only the HTTP status on failure, never the remote body.
- Validate username/password as header values, restrict subdomain to
  [A-Za-z0-9-], reject query strings and build /update with url::Url.
- Allow clippy::large_enum_variant on SourceConfig (CI uses -D warnings).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Reject propagation_delay over 300, query strings, control characters
  in the password, and dotted subdomains.
- Reject more than 2 domains; check the password is redacted in Debug.
- Check failures don't echo the server body; cover a trailing /update/.
- Collapse a nested if in the mock acme-dns server (clippy).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@debiansid
debiansid merged commit f3bdb1b into dev Nov 17, 2026
18 checks passed
@debiansid
debiansid deleted the feat/acme-dns branch November 17, 2026 15:11
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