Repository navigation
mod_md: Honour the Retry-After header of ACME responses (BZ 70282) - #868
arturobernalg wants to merge 2 commits into
Conversation
Add ap_parse_retry_after() to parse the value of a Retry-After header, either delay-seconds or an HTTP-date as defined in RFC 9110, section 5.6.7. mod_md uses it as RFC 8555 recommends: when polling orders and authorizations, after finalizing an order and when a request is rate limited. A hint beyond the timeout is waited for only until the deadline, and the wait ends early on shutdown. a2md does not link httpd and carries its own copy of the parser. PR 70282.
Oh, that's a bit painful. Maybe it's a bad idea putting this in httpd then? Just keep the new API in mod_md in a way that a2md & mod_md can share a single copy of the code. We can always work out how to abstract it out later if there is another caller which needs this. |
Per review feedback, this keeps the Retry-After parser (RFC 9110, section 10.2.3) entirely inside mod_md instead of adding it as a new core httpd API. md_util_parse_retry_after() lives in md_util.c/md_util.h, has no httpd dependency, and is compiled unchanged into both mod_md (as a DSO) and a2md (MD_A2MD_BUILD, no httpd link). md_acme.c now has a single call site; the former #ifdef MD_A2MD_BUILD duplicate parser is gone. include/httpd.h, include/ap_mmn.h, server/util.c and test/unit/util.c are unchanged from trunk: no new public API, no MMN bump. The parser's regression tests move from test/unit/util.c to a new support/a2md/test_retry_after, a small standalone program (a2md does not link libcheck) linked against the same $(MD_LIB_OBJS) a2md itself ships. Wired into `make check` as check-retry-after, added to CHECK_TARGETS only when a2md is enabled (support/a2md/config2.m4), so `make check` neither runs nor requires it when a2md is disabled. changes-entries/70282.txt (the core entry) is removed; changes-entries/md-retry-after.txt (the mod_md entry) is unchanged. Verified with a clean build against the system APR/APR-util: both check-unittests and check-retry-after pass, with and without a2md enabled, plain and under ASan+UBSan (zero reports). The existing test/modules/md pyhttpd suite passes (81 passed, 0 failed); its remaining errors are Pebble not being available in this environment, unrelated to this change.
|
Thanks, @notroj . I've moved the Retry-After parser into |
Bugzilla: https://bz.apache.org/bugzilla/show_bug.cgi?id=70282
mod_md ignores the Retry-After header of ACME responses. RFC 8555 recommends honouring it, and ignoring it makes mod_md race against pebble in CI.
This adds ap_parse_retry_after() to the core. It accepts delay-seconds or an HTTP-date in any of the three formats of RFC 9110, section 5.6.7, and rejects everything else, such as time zones other than GMT, text after the date, or lists. An HTTP-date is read against the Date header of the response, so a skewed server clock does not matter. The day name is checked for its syntax only, as RFC 9110 does not require rejecting an inconsistent one.
mod_md uses it when polling orders and authorizations, after the challenge POST and the finalize response, and on rate limited errors, where the job is rescheduled no earlier than the CA asked, capped at one day. A hint beyond the timeout is waited for only until the deadline, then one last poll is made. The wait ends early when the server stops or restarts, and such a cancelled run is not counted as a renewal error.
Validated on Linux:
Limits of this validation:
The new tests are libcheck unit tests in test/unit/util.c, not pyhttpd tests. The existing test/modules/md suite covers the mod_md side.
(see
SECURITY.mdandhttps://www.apache.org/security/#reporting-a-vulnerability).
APLOGNO()tag;numbers are assigned by a committer at merge time (see
docs/log-message-tags/README).changes-entries/*.txtfile is included,following the template in
README.CHANGES(not needed otherwise).test/modules/xxxdirectory matching themodules/xxxmodule source,or
test/modules/corefor core server changes. On Unix, verify thesepass locally with e.g.
make check-pytest PYTEST_DIRS=test/modules/xxx.