]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: acme: split the CLI wait from the resolve wait
authorWilliam Lallemand <wlallemand@haproxy.com>
Thu, 2 Apr 2026 13:16:29 +0000 (15:16 +0200)
committerWilliam Lallemand <wlallemand@haproxy.com>
Thu, 2 Apr 2026 13:54:02 +0000 (15:54 +0200)
Add a new state ACME_CLI_WAIT which allows to split the CLI wait logic
from the resolve wait logic.

include/haproxy/acme-t.h
src/acme.c

index 86b2256aa862c6150db3d0567b4f62158813e9bb..50e02f128b5a021f0976e8bf28c04d29c4baa32f 100644 (file)
@@ -51,6 +51,7 @@ enum acme_st {
        ACME_NEWACCOUNT,
        ACME_NEWORDER,
        ACME_AUTH,
+       ACME_CLI_WAIT,               /* wait for the ACME_RDY_CLI */
        ACME_RSLV_WAIT,
        ACME_RSLV_TRIGGER,
        ACME_RSLV_READY,
index bb5d86aa7a16d3074b767699f20676d001165bc3..4cf873c32e3602453f87c0c2150a8e0ec1709ab0 100644 (file)
@@ -121,6 +121,7 @@ static void acme_trace(enum trace_level level, uint64_t mask, const struct trace
                        case ACME_NEWACCOUNT:     chunk_appendf(&trace_buf, "ACME_NEWACCOUNT");   break;
                        case ACME_NEWORDER:       chunk_appendf(&trace_buf, "ACME_NEWORDER");     break;
                        case ACME_AUTH:           chunk_appendf(&trace_buf, "ACME_AUTH");         break;
+                       case ACME_CLI_WAIT :      chunk_appendf(&trace_buf, "ACME_CLI_WAIT");    break;
                        case ACME_RSLV_WAIT:      chunk_appendf(&trace_buf, "ACME_RSLV_WAIT");    break;
                        case ACME_RSLV_TRIGGER:   chunk_appendf(&trace_buf, "ACME_RSLV_TRIGGER");   break;
                        case ACME_RSLV_READY:     chunk_appendf(&trace_buf, "ACME_RSLV_READY");   break;
@@ -2386,7 +2387,7 @@ re:
                                }
                                if ((ctx->next_auth = ctx->next_auth->next) == NULL) {
                                        if (strcasecmp(ctx->cfg->challenge, "dns-01") == 0 && ctx->cfg->cond_ready)
-                                               st = ACME_RSLV_WAIT;
+                                               st = ACME_CLI_WAIT;
                                        else
                                                st = ACME_CHALLENGE;
                                        ctx->next_auth = ctx->auths;
@@ -2395,7 +2396,7 @@ re:
                                goto nextreq;
                        }
                break;
-               case ACME_RSLV_WAIT: {
+               case ACME_CLI_WAIT: {
                        struct acme_auth *auth;
                        int all_cond_ready = ctx->cfg->cond_ready;
 
@@ -2415,6 +2416,25 @@ re:
                        if ((ctx->cfg->cond_ready & ACME_RDY_CLI) && !(all_cond_ready & ACME_RDY_CLI))
                                goto wait;
 
+                       /* next step */
+                       st = ACME_RSLV_WAIT;
+                       goto nextreq;
+               }
+               break;
+               case ACME_RSLV_WAIT: {
+                       struct acme_auth *auth;
+                       int all_cond_ready = ctx->cfg->cond_ready;
+
+                       for (auth = ctx->auths; auth != NULL; auth = auth->next) {
+                               all_cond_ready &= auth->ready;
+                       }
+
+                       /* if everything is ready, let's do the challenge request */
+                       if ((all_cond_ready & ctx->cfg->cond_ready) == ctx->cfg->cond_ready) {
+                               st = ACME_CHALLENGE;
+                               goto nextreq;
+                       }
+
                        /* set the start time of the DNS checks so we can apply
                         * the timeout */
                        if (ctx->dnsstarttime == 0)