Skip to content

ACME: allow delayed challenge acceptance per solver - #8794

Closed
wallrj wants to merge 9 commits into
cert-manager:masterfrom
wallrj:1292-hybrid
Closed

wallrj wants to merge 9 commits into
cert-manager:masterfrom
wallrj:1292-hybrid

Conversation

@wallrj

@wallrj wallrj commented May 15, 2026 •

Copy link
Copy Markdown
Member

Fixes: #1292

It adds a per-solver acceptChallengeAfter escape hatch for ACME challenges:

  • cert-manager still presents the challenge as usual;
  • cert-manager still performs the existing self-check;
  • if the self-check succeeds, cert-manager accepts the challenge immediately; and
  • if the self-check does not succeed, cert-manager accepts the challenge once the configured delay since presentation has elapsed.

The intention is to help in environments where cert-manager cannot reliably observe the same validation path as the ACME server, for example split-horizon DNS, NAT loopback limitations, or public/private ingress asymmetry.

This is a smaller and simpler version of the approach previously explored in #5006. It keeps the public API small, but still factors the controller logic through an internal readiness evaluator so the behaviour is easier to test and reason about.

Prototype docs for the next minor release are in cert-manager/website#2101.

API shape in this prototype

spec:
  acme:
    solvers:
    - http01:
        ingress:
          ingressClassName: nginx
      acceptChallengeAfter: 30s

This also adds status.presentedAt on Challenge so the delay is measured from first successful presentation.

Implementation notes

  • default behaviour is unchanged when acceptChallengeAfter is not set
  • successful self-check still short-circuits the delay
  • delayed acceptance is implemented through controller-internal readiness helpers rather than a larger public readiness API
  • generated code and CRDs have been refreshed with make generate-codegen generate-crds

Testing

I have run:

  • go test ./pkg/controller/acmechallenges -count=1
  • make generate-codegen generate-crds

The unit coverage in readiness_test.go and sync_test.go includes:

  • strict self-check behaviour when no delay is configured
  • successful self-check short-circuiting the delay
  • retry scheduling while part-way through the delay window
  • proceeding once the configured delay has elapsed even if the self-check is still failing

I have not added a new ACME e2e test for the delayed-acceptance path in this PR. The reason is that the distinguishing behaviour here requires a test topology where cert-manager and the ACME server intentionally observe different validation paths. The existing e2e environment is set up so that both normally see the same working path, so a new e2e would either be weak wiring coverage only or require much more invasive and potentially flaky test setup. For this PR, I think the targeted unit coverage gives better signal.

TODO

Kind

/kind feature

Release Note

Add an optional `acceptChallengeAfter` field to ACME HTTP01 and DNS01 solvers so cert-manager can accept a challenge after a configured delay when self-checks cannot succeed from cert-manager's own network or DNS viewpoint.

Relates to #1292.

@cert-manager-prow

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@cert-manager-prow cert-manager-prow Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels May 15, 2026
@cert-manager-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign hjoshi123 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@cert-manager-prow cert-manager-prow Bot added area/acme Indicates a PR directly modifies the ACME Issuer code area/api Indicates a PR directly modifies the 'pkg/apis' directory area/deploy Indicates a PR modifies deployment configuration area/testing Issues relating to testing size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 15, 2026
@cert-manager-prow cert-manager-prow Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels May 15, 2026
@wallrj

wallrj commented May 18, 2026 •

Copy link
Copy Markdown
Member Author

One API design question I looked at was whether this should introduce a Presented condition instead of adding status.presentedAt.

I think a Presented condition would be a reasonable, more Kubernetes-idiomatic shape in isolation, and it could make tooling such as kubectl wait a bit nicer. The Kubernetes API conventions explicitly call out both conditions and dedicated status fields/timestamps as typical status properties: https://github.com/kubernetes/community/blob/main/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties

I have still kept presentedAt for this PR because:

  • Challenge does not currently expose status.conditions at all;
  • cert-manager already has precedent for dedicated status timestamps such as failureTime, lastFailureTime, renewalTime, etc.; and
  • introducing Challenge conditions here would broaden the API and controller design quite a bit, pushing this PR back towards the larger shape previously explored in WIP: Allow ignoring ACME challenge self check failures #5006.

So for now this PR keeps the existing status.presented boolean and records the presentation timestamp alongside it. If maintainers want to move Challenge towards conditions in future, that still seems like a sensible follow-up design discussion.

@wallrj
wallrj marked this pull request as ready for review May 18, 2026 06:00
@cert-manager-prow cert-manager-prow Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 18, 2026
@wallrj

wallrj commented May 20, 2026

Copy link
Copy Markdown
Member Author

/kind feature

@cert-manager-prow cert-manager-prow Bot added kind/feature Categorizes issue or PR as related to a new feature. and removed needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels May 20, 2026
@wallrj

wallrj commented May 20, 2026

Copy link
Copy Markdown
Member Author

One observability point I looked at was whether this PR should also add a metric for self-check timing.

I have not included one here. We do already expose ACME client request metrics, but I do not think there is currently a metric for challenge self-check or readiness duration.

I think that is better treated as a follow-up, because the right shape is not entirely obvious once delayed acceptance is possible. For example, there is a design choice between measuring time to successful self-check, time to challenge acceptance, or distinguishing acceptance via self-check from acceptance via delay fallback.

For now, status.presentedAt improves object-level observability without broadening the metrics surface in this PR. If maintainers think timing metrics would be useful, I think a separate follow-up focused on challenge readiness / acceptance duration would be the better place to design them.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an ACME “escape hatch” to allow accepting challenges after a per-solver delay when cert-manager’s self-check cannot reliably observe the same validation path as the ACME server (e.g., split-horizon DNS, NAT loopback issues). It does this by adding spec.acme.solvers[].acceptChallengeAfter and recording status.presentedAt on Challenge so the delay can be measured from first successful presentation.

Changes:

  • Add acceptChallengeAfter to ACMEChallengeSolver and generate CRDs/OpenAPI/applyconfigurations accordingly.
  • Add status.presentedAt to ChallengeStatus and set/reset it in the challenges controller.
  • Factor readiness/acceptance decision logic into a controller-internal readiness evaluator with new unit coverage, plus a small e2e assertion that presentedAt is set.

Reviewed changes

Copilot reviewed 17 out of 24 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/unit/gen/challenge.go Adds unit-test helpers for presentedAt and acceptChallengeAfter.
test/e2e/suite/issuers/acme/certificate/webhook.go Extends e2e assertions to require status.presentedAt once presented.
pkg/controller/acmechallenges/sync.go Records presentedAt, resets it on finalization, and routes acceptance through readiness evaluation.
pkg/controller/acmechallenges/sync_test.go Adds/adjusts sync tests for presentedAt and delayed acceptance behavior.
pkg/controller/acmechallenges/readiness.go Introduces internal readiness evaluators (strict self-check vs delay-after-presentation).
pkg/controller/acmechallenges/readiness_test.go Adds unit tests covering readiness evaluation behavior.
pkg/controller/acmechallenges/controller.go Wires controller clock into the challenges controller for deterministic time handling.
pkg/client/applyconfigurations/internal/internal.go Updates applyconfiguration schema for new fields.
pkg/client/applyconfigurations/acme/v1/challengestatus.go Adds applyconfig support/docs for presentedAt.
pkg/client/applyconfigurations/acme/v1/acmechallengesolver.go Adds applyconfig support/docs for acceptChallengeAfter.
pkg/apis/acme/v1/types_issuer.go Adds public API field acceptChallengeAfter on solver.
pkg/apis/acme/v1/types_challenge.go Adds status.presentedAt to Challenge status API.
pkg/apis/acme/v1/zz_generated.deepcopy.go Regenerates deepcopy for new fields.
internal/apis/acme/types_issuer.go Mirrors internal API field for acceptChallengeAfter.
internal/apis/acme/types_challenge.go Mirrors internal API field for presentedAt.
internal/apis/acme/zz_generated.deepcopy.go Regenerates internal deepcopy for new fields.
internal/apis/acme/v1/zz_generated.conversion.go Regenerates conversions for new fields and import alias adjustments.
internal/generated/openapi/zz_generated.openapi.go Regenerates OpenAPI for new fields.
deploy/crds/cert-manager.io_issuers.yaml CRD regen to include acceptChallengeAfter.
deploy/crds/cert-manager.io_clusterissuers.yaml CRD regen to include acceptChallengeAfter.
deploy/crds/acme.cert-manager.io_challenges.yaml CRD regen to include acceptChallengeAfter and status.presentedAt.
deploy/charts/cert-manager/templates/crd-cert-manager.io_issuers.yaml Helm CRD template regen for acceptChallengeAfter.
deploy/charts/cert-manager/templates/crd-cert-manager.io_clusterissuers.yaml Helm CRD template regen for acceptChallengeAfter.
deploy/charts/cert-manager/templates/crd-acme.cert-manager.io_challenges.yaml Helm CRD template regen for acceptChallengeAfter and status.presentedAt.
Files not reviewed (6)
  • internal/apis/acme/v1/zz_generated.conversion.go: Language not supported
  • internal/apis/acme/zz_generated.deepcopy.go: Language not supported
  • pkg/apis/acme/v1/zz_generated.deepcopy.go: Language not supported
  • pkg/client/applyconfigurations/acme/v1/acmechallengesolver.go: Language not supported
  • pkg/client/applyconfigurations/acme/v1/challengestatus.go: Language not supported
  • pkg/client/applyconfigurations/internal/internal.go: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/controller/acmechallenges/sync.go Resolved
@wallrj

wallrj commented May 22, 2026

Copy link
Copy Markdown
Member Author

/retest

@wallrj

wallrj commented May 23, 2026

Copy link
Copy Markdown
Member Author

I dug into the latest pull-cert-manager-master-e2e-v1-35 failure.

This one looks like infra rather than a branch regression:

  • the job was aborted, not failed by a test assertion
  • podinfo.json for build 2057715292406026240 shows DisruptionTarget=True with reason PreemptionByScheduler
  • the prow pod was then deleted while the job was still in setup, which matches the GitHub check summary (Pod got deleted unexpectedly)

There also seems to be a broader issue with the same job on unrelated open PRs: for example #8808 and #8814 are both hanging in e2e-setup-samplewebhook until the 2h job timeout, so e2e-v1-35 looks generally unhealthy at the moment.

/retest

@inteon

inteon commented May 26, 2026

Copy link
Copy Markdown
Member

/test pull-cert-manager-master-e2e-v1-35

@wallrj

wallrj commented May 31, 2026

Copy link
Copy Markdown
Member Author

The latest pull-cert-manager-master-e2e-v1-35 failure still appears consistent with the earlier infrastructure problem rather than with this change.

From the available build log, the job got through kind setup, cert-manager install, Pebble install, and the samplewebhook Helm invocation, then hit the overall 2 hour timeout without any sign that it had progressed into Ginkgo test execution.

As that looks like the same setup-stage mode of failure we were seeing before, I think it is worth retrying now that the underlying e2e infrastructure problem may have been addressed.

/retest

@maelvls

maelvls commented Jun 2, 2026 •

Copy link
Copy Markdown
Member

Took me a while to remember why we didn't accept the idea of adding smth like disableSelfCheck: true on the issuer. It all stems from RFC 8555 (Clients SHOULD NOT respond to challenges until they believe that the server's queries will succeed) and the fact that other impl (certbot and traefik) have a work around... and we don't want people to go away from cert-manager.

The RFC says "SHOULD NOT", and not "MUST NOT", so it feels OK to me. And since the default is still to fail if the self-check doesn't succeed, I think public ACME issuers like Let's Encrypt won't come to us saying that cert-manager is hammering them... hopefully.

Now, what about the risk of rate limit with most public ACME issuers? For Let's Encrypt, the rate limit for failed validation is 5 failures per account, per hostname, per hour. Using Let's Encrypt + acceptChallengeAfter: 0s (or any short duration) may cause issues... although it doesn't seem that bad: the user will notice that the challenge keeps failing and will have to wait at most 60 minutes before being able to fix the issue, so no outage.

I don't really know what the risk of having a Let's Encrypt account with lots of failed validations would be. Maybe it would increase the risk of hitting other rate limits if an order has lots of hostnames but only one is failing... I'm thinking the regular certificaterequest exponential backoff would kick in, but I'm not sure. It would be great to have some explanation of these risks (if someone understands them) in the docs.

Also, why should cert-manager perform the self-check when acceptChallengeAfter is used? The user who created this issuer/clusterissuer knows that cert-manager's self-checks will always fail in their setup, so what they mean by acceptChallengeAfter: 30s is "please ignore the checks and tell ACME to verify my challenges after 30 seconds". In that case, wouldn't a better name be:

waitInsteadOfSelfCheck: 30s

That way, it's clear that cert-manager's self checks aren't worth doing. And it would match certbot's behavior.

I can't see a scenario where self-checks normally work and someone would still use acceptChallengeAfter. What would be the use-case?

@wallrj

wallrj commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

Superseded by #8858.

I have opened a fresh replacement PR because the review feedback changed both the public field name and the feature semantics, so keeping the old PR would have left a confusing review trail around the earlier hybrid design.

@wallrj wallrj closed this Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/acme Indicates a PR directly modifies the ACME Issuer code area/api Indicates a PR directly modifies the 'pkg/apis' directory area/deploy Indicates a PR modifies deployment configuration area/testing Issues relating to testing dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. kind/feature Categorizes issue or PR as related to a new feature. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allowing skipping HTTP01 and DNS01 self-check on a per-solver basis

4 participants