From: William Lallemand Date: Tue, 24 Nov 2026 15:41:22 +0000 (+0000) Subject: BUG/MEDIUM: acme: distinguish wildcard CLI and Lua acknowledgements X-Git-Url: https://git.kaiwu.me/http/%7B@url%7D?a=commitdiff_plain;h=6fd03f9fb817bb69c528c3ae3e60129d7b3f8996;p=haproxy.git BUG/MEDIUM: acme: distinguish wildcard CLI and Lua acknowledgements Wildcard and non-wildcard authorizations expose the same base DNS name. Matching readiness on that name alone acknowledges both authorizations after only one token has been deployed, while a literal wildcard identifier cannot match. Retain the authorization's wildcard flag and match it together with the base domain. Accept *.domain only for the wildcard authorization, expose the flag in Lua deployment events, and print the matching CLI command without changing the DNS TXT owner. The CLI bug dates back to 9ee14ed2d9 ("MEDIUM: acme: allow to wait and restart the task for DNS-01"), also backported to 3.2 as c68fc8a9be. The shared helper and Lua readiness API were introduced in 3.5. This must be backported to 3.4, 3.3 and 3.2. Adapt the CLI fix to their inline CLI handlers; the Lua helper and deployment-event changes are 3.5-only and must not be backported as new features. --- diff --git a/include/haproxy/acme-t.h b/include/haproxy/acme-t.h index fe7e95d3e..28d43999e 100644 --- a/include/haproxy/acme-t.h +++ b/include/haproxy/acme-t.h @@ -88,6 +88,7 @@ struct acme_auth { struct ist auth; /* auth URI */ struct ist chall; /* challenge URI */ struct ist token; /* token */ + int wildcard; /* authorization covers *.dns */ int validated; /* already validated */ struct acme_rslv *rslv; /* acme dns-01 resolver */ int ready; /* is the challenge ready ? */ @@ -142,6 +143,7 @@ struct event_hdl_cb_data_acme_deploy { struct { char *crtname; /* certificate store name (heap-allocated) */ char *domain; /* domain being challenged (heap-allocated) */ + int wildcard; /* authorization covers *.domain */ char *thumbprint; /* account key JWK thumbprint (heap-allocated) */ char *dns_record; /* DNS TXT record value to set (heap-allocated) */ char *provider; /* DNS provider name (heap-allocated, may be NULL) */ diff --git a/src/acme.c b/src/acme.c index 377af2a7d..1c04e2672 100644 --- a/src/acme.c +++ b/src/acme.c @@ -2069,6 +2069,7 @@ int acme_res_auth(struct task *task, struct acme_ctx *ctx, struct acme_auth *aut t2->data = ret; mjson_get_bool(hc->res.buf.area, hc->res.buf.data, "$.wildcard", &wildcard); + auth->wildcard = wildcard; auth->dns = istdup(ist2(t2->area, t2->data)); @@ -2204,8 +2205,8 @@ int acme_res_auth(struct task *task, struct acme_ctx *ctx, struct acme_auth *aut auth->token = istdup(ist2(dns_record->area, dns_record->data)); if (ctx->cfg->cond_ready & ACME_RDY_CLI) - send_log(NULL, LOG_NOTICE,"acme: %s: dns-01 requires to set the \"_acme-challenge.%.*s\" TXT record to \"%.*s\" and use the \"acme challenge_ready %s domain %.*s\" command over the CLI\n", - ctx->store->path, (int)auth->dns.len, auth->dns.ptr, (int)auth->token.len, auth->token.ptr, ctx->store->path, (int)auth->dns.len, auth->dns.ptr); + send_log(NULL, LOG_NOTICE,"acme: %s: dns-01 requires to set the \"_acme-challenge.%.*s\" TXT record to \"%.*s\" and use the \"acme challenge_ready %s domain %s%.*s\" command over the CLI\n", + ctx->store->path, (int)auth->dns.len, auth->dns.ptr, (int)auth->token.len, auth->token.ptr, ctx->store->path, auth->wildcard ? "*." : "", (int)auth->dns.len, auth->dns.ptr); /* dump to the "dpapi" sink */ line[nmsg++] = ist("acme deploy "); @@ -2242,6 +2243,7 @@ int acme_res_auth(struct task *task, struct acme_ctx *ctx, struct acme_auth *aut cb_data.safe.crtname = strdup(ctx->store->path); cb_data.safe.domain = isttest(auth->dns) ? strndup(auth->dns.ptr, auth->dns.len) : NULL; + cb_data.safe.wildcard = auth->wildcard; cb_data.safe.thumbprint = ctx->cfg->account.thumbprint ? strdup(ctx->cfg->account.thumbprint) : NULL; cb_data.safe.dns_record = strndup(dns_record->area, dns_record->data); cb_data.safe.provider = ctx->cfg->provider ? strdup(ctx->cfg->provider) : NULL; @@ -3593,6 +3595,8 @@ int acme_challenge_ready(const char *crt, const char *dns) struct ebmb_node *node = NULL; struct acme_ctx *ctx = NULL; struct acme_auth *auth = NULL; + int wildcard = strncmp(dns, "*.", 2) == 0; + struct ist domain = ist(dns + (wildcard ? 2 : 0)); int found = 0; int remain = 0; @@ -3607,7 +3611,7 @@ int acme_challenge_ready(const char *crt, const char *dns) if (ctx->cfg->cond_ready & ACME_RDY_CLI) auth = ctx->auths; while (auth) { - if (isteq(ist(dns), auth->dns)) { + if (auth->wildcard == wildcard && isteq(domain, auth->dns)) { if ((auth->ready & ACME_RDY_CLI) == 0) { auth->ready |= ACME_RDY_CLI; found++; @@ -3772,7 +3776,7 @@ INITCALL0(STG_REGISTER, __acme_init); static int class_acme_event_ref; /* Push a new AcmeEvent object for an ACME_DEPLOY event onto the Lua stack. - * The object exposes crtname, domain, thumbprint, dns_record fields, and + * The object exposes crtname, domain, wildcard, thumbprint, dns_record fields, and * optionally provider and vars if they were configured. */ static void hlua_fcn_new_acme_event_deploy(lua_State *L, const struct event_hdl_cb_data_acme_deploy *e) @@ -3788,6 +3792,9 @@ static void hlua_fcn_new_acme_event_deploy(lua_State *L, const struct event_hdl_ lua_pushstring(L, e->safe.domain ? e->safe.domain : ""); lua_setfield(L, -2, "domain"); + lua_pushboolean(L, e->safe.wildcard); + lua_setfield(L, -2, "wildcard"); + lua_pushstring(L, e->safe.thumbprint ? e->safe.thumbprint : ""); lua_setfield(L, -2, "thumbprint");