fix: migrate POST/PATCH to v2 API to fix DNS-01 ACME challenge - #6
fix: migrate POST/PATCH to v2 API to fix DNS-01 ACME challenge#6WEBzaytsev wants to merge 1 commit into
Conversation
|
Hey, thanks for taking the time to investigate this and put together such a detailed PR — really appreciate it! I've just re-tested the library end-to-end with Caddy using the The reason I deliberately stayed on v1 for POST/PATCH is that v2 requires subdomain pre-creation before you can attach records to it — as you can see from your own implementation, it adds a fair amount of extra logic. The v1 API doesn't have that requirement, which keeps things simpler. On top of that, v1 doesn't reject That said, if |
Problem
DNS-01 ACME challenges fail with
HTTP 400: bad_subdomain_namewhen usingacme_dns timewebin Caddy. The provider is unable to create TXT recordsfor
_acme-challenge.*subdomains.Root Cause
The v1 POST endpoint (
/api/v1/domains/{zone}/dns-records) rejects namesstarting with
_in thesubdomainrequest body field. The provider wassending the relative name (e.g.
_acme-challenge.sub) instead of the fullFQDN (
_acme-challenge.sub.example.com) that v1 requires.Additionally, the v1 POST and PATCH endpoints are marked as
deprecatedinthe Timeweb OpenAPI spec.
Solution
Migrate
createRecordandupdateRecordto the v2 API, where the targetFQDN is specified in the URL path (already used by
deleteRecord) and therequest body contains no
subdomainfield:POST /api/v2/domains/_acme-challenge.sub.example.com/dns-records {"type":"TXT","value":"...","ttl":600}Changes
client.go:createRecordandupdateRecordnow usev2+getFQDN()in the URL path, consistent with the existing
deleteRecordmodels.go: replacedTimewebRecord/SavedRecord(v1) withTimewebRecordV2/RecordResponseV2/SavedRecordV2(v2); simplifiedlibdnsToRecord— nosubdomainfield, nozoneparameter neededuser-records) stays on v1 — no v2 equivalent exists in the specReferences
Timeweb OpenAPI spec:
POST /api/v2/domains/{fqdn}/dns-recordsRFC 8555 §8.4 (DNS-01 challenge)