Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run only one order at a time #74

Open
LeGmask opened this issue Jan 23, 2025 · 11 comments
Open

Run only one order at a time #74

LeGmask opened this issue Jan 23, 2025 · 11 comments

Comments

@LeGmask
Copy link

LeGmask commented Jan 23, 2025

In my case, I use a CNAME record for acme challenge entries, by doing this, I should only run on order at a time.
As of today, if many order runs at the same time, only one will be successful.

Could you add something such as a way to reduce the number of workers?

Thank you by advance :)

Also seems like that certificates with multiple domains (and again same CNAME for all) are stuck while doing challenge.

Image

certwarden  | 2025-01-23T12:53:43.204Z	info	orders/fulfilling_do.go:24	orders: fulfilling worker 0: ordering order id 19 (certificate name: tvn7.fr, subject: tvn7.fr)
certwarden  | 2025/01/23 12:53:43 [INFO] Found CNAME entry for "_acme-challenge.tvn7flix.fr.": "acmechallenge.inpt.fr."
certwarden  | 2025/01/23 12:53:43 [INFO] Found CNAME entry for "_acme-challenge.tvn7.fr.": "acmechallenge.inpt.fr."
certwarden  | 2025-01-23T12:53:47.844Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.tvn7flix.fr: propagated: 0 (0%, min: 100%), will check again in 16.1s
certwarden  | 2025-01-23T12:53:56.208Z	info	challenges/solver.go:142	challenges: challenge pending status (https://acme-v02.api.letsencrypt.org/acme/chall/112651704/465018868325/6_xYnA) not a final status, will check again in 6.1s
certwarden  | 2025/01/23 12:54:02 [INFO] Found CNAME entry for "_acme-challenge.tvn7.fr.": "acmechallenge.inpt.fr."
certwarden  | 2025/01/23 12:54:02 [INFO] Found CNAME entry for "_acme-challenge.tvn7.fr.": "acmechallenge.inpt.fr."
certwarden  | 2025-01-23T12:54:04.875Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.tvn7.fr: propagated: 2 (67%, min: 100%), will check again in 15s
certwarden  | 2025-01-23T12:54:05.759Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.tvn7flix.fr: propagated: 0 (0%, min: 100%), will check again in 20.1s
certwarden  | 2025-01-23T12:54:21.990Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.tvn7.fr: propagated: 2 (67%, min: 100%), will check again in 18s
certwarden  | 2025-01-23T12:54:26.338Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.tvn7flix.fr: propagated: 0 (0%, min: 100%), will check again in 24.4s
certwarden  | 2025-01-23T12:54:47.351Z	info	challenges/solver.go:142	challenges: challenge pending status (https://acme-v02.api.letsencrypt.org/acme/chall/112651704/465018868345/xY91rA) not a final status, will check again in 4.6s
certwarden  | 2025-01-23T12:54:50.946Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.tvn7flix.fr: propagated: 0 (0%, min: 100%), will check again in 30.1s
certwarden  | 2025-01-23T12:54:52.040Z	info	challenges/solver.go:142	challenges: challenge pending status (https://acme-v02.api.letsencrypt.org/acme/chall/112651704/465018868345/xY91rA) not a final status, will check again in 12.9s
certwarden  | 2025/01/23 12:55:05 [INFO] Found CNAME entry for "_acme-challenge.tvn7.fr.": "acmechallenge.inpt.fr."
certwarden  | 2025-01-23T12:55:23.191Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.tvn7flix.fr: propagated: 0 (0%, min: 100%), will check again in 29.5s
certwarden  | 2025-01-23T12:55:54.871Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.tvn7flix.fr: propagated: 0 (0%, min: 100%), will check again in 29.9s
certwarden  | 2025-01-23T12:56:26.590Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.tvn7flix.fr: propagated: 0 (0%, min: 100%), will check again in 40.7s
certwarden  | 2025-01-23T12:57:09.171Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.tvn7flix.fr: propagated: 0 (0%, min: 100%), will check again in 47.4s
certwarden  | 2025-01-23T12:58:06.583Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.tvn7flix.fr: propagated: 0 (0%, min: 100%), will check again in 1m2.7s
certwarden  | 2025-01-23T12:59:11.035Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.tvn7flix.fr: propagated: 0 (0%, min: 100%), will check again in 1m17.8s
certwarden  | 2025-01-23T13:00:29.993Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.tvn7flix.fr: propagated: 0 (0%, min: 100%), will check again in 1m41.4s
certwarden  | 2025-01-23T13:02:15.523Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.tvn7flix.fr: propagated: 0 (0%, min: 100%), will check again in 2m13.3s
@gregtwallace
Copy link
Owner

gregtwallace commented Jan 23, 2025

I’ll need to investigate this more. The desired behavior is how I thought I designed it (it was originally done due to wildcards and it was working). I’ll need to look back at it since the cname alias option was added later.

@gregtwallace
Copy link
Owner

gregtwallace commented Jan 25, 2025

This actually was working as intended. However, it seemed like there was a minor (but consistent) "hangover" when reusing the same domain for a challenge with a CNAME. I'm not sure why it didn't impact wild card certificates when not using a CNAME, which was the original reason I had to build it like this.

I couldn't find any elegant solution other than to add a delay when re-using the same domain / validation resource. This consistently fixed the issue in testing.

@gregtwallace
Copy link
Owner

Building the new release now. Please let me know if you encounter this issue again.

@LeGmask
Copy link
Author

LeGmask commented Jan 28, 2025

Sorry for the lag, but I can confirm this doesn't resolve the issue for now. I've tried with another certificate that have the same problematic :

Image

certwarden  | 2025-01-28T13:54:44.829Z	info	orders/fulfilling_do.go:24	orders: fulfilling worker 2: ordering order id 29 (certificate name: galileo.bde.inp-toulouse.fr, subject: galileo.bde.inp-toulouse.fr)
certwarden  | 2025/01/28 13:54:45 [INFO] Found CNAME entry for "_acme-challenge.smtp.inpt.fr.": "acmechallenge.inpt.fr."
certwarden  | 2025/01/28 13:54:45 [INFO] Found CNAME entry for "_acme-challenge.galileo.bde.inp-toulouse.fr.": "acmechallenge.inpt.fr."
certwarden  | 2025-01-28T13:54:47.619Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 1 (33%, min: 100%), will check again in 15.9s
certwarden  | 2025-01-28T13:54:58.279Z	info	challenges/solver.go:146	challenges: challenge pending status (https://acme-v02.api.letsencrypt.org/acme/chall/112651704/467511290455/1dN9yQ) not a final status, will check again in 4.2s
certwarden  | 2025/01/28 13:55:02 [INFO] Found CNAME entry for "_acme-challenge.galileo.bde.inp-toulouse.fr.": "acmechallenge.inpt.fr."
certwarden  | 2025-01-28T13:55:05.611Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 0 (0%, min: 100%), will check again in 16s
certwarden  | 2025-01-28T13:55:24.847Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 0 (0%, min: 100%), will check again in 20.9s
certwarden  | 2025-01-28T13:55:45.914Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 0 (0%, min: 100%), will check again in 23.1s
certwarden  | 2025-01-28T13:56:09.230Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 0 (0%, min: 100%), will check again in 36.7s
certwarden  | 2025-01-28T13:56:47.592Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 0 (0%, min: 100%), will check again in 37.5s
certwarden  | 2025-01-28T13:57:25.410Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 0 (0%, min: 100%), will check again in 46.7s
certwarden  | 2025-01-28T13:58:12.433Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 0 (0%, min: 100%), will check again in 58.1s
certwarden  | 2025-01-28T13:59:10.766Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 0 (0%, min: 100%), will check again in 1m5.5s
certwarden  | 2025-01-28T14:00:16.452Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 0 (0%, min: 100%), will check again in 1m2.5s
certwarden  | 2025-01-28T14:01:21.051Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 0 (0%, min: 100%), will check again in 1m41.2s
certwarden  | 2025-01-28T14:03:02.326Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 0 (0%, min: 100%), will check again in 2m10.1s
certwarden  | 2025-01-28T14:05:12.587Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 0 (0%, min: 100%), will check again in 2m9.4s
certwarden  | 2025-01-28T14:07:23.753Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 0 (0%, min: 100%), will check again in 2m16.6s
certwarden  | 2025-01-28T14:09:42.582Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 0 (0%, min: 100%), will check again in 2m20s
certwarden  | 2025-01-28T14:12:06.681Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 0 (0%, min: 100%), will check again in 2m22.8s
certwarden  | 2025-01-28T14:14:29.718Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 0 (0%, min: 100%), will check again in 2m11.1s
certwarden  | 2025-01-28T14:16:40.954Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 0 (0%, min: 100%), will check again in 2m18.7s
certwarden  | 2025-01-28T14:19:01.759Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 0 (0%, min: 100%), will check again in 2m17.5s
certwarden  | 2025-01-28T14:21:19.475Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 0 (0%, min: 100%), will check again in 1m46s
certwarden  | 2025-01-28T14:23:05.933Z	error	orders/fulfilling_do.go:99	orders: fulfilling worker 2: fulfill auths error: challenges: solving failed: dns record didn't propagate
certwarden  | 2025/01/28 14:23:06 [INFO] Found CNAME entry for "_acme-challenge.smtp.inpt.fr.": "acmechallenge.inpt.fr."
certwarden  | 2025-01-28T14:23:06.188Z	info	orders/fulfilling_do.go:100	orders: fulfilling worker 2: order 29 done

But after one retry, it worked successfully:

certwarden  | 2025-01-28T14:24:10.992Z	info	orders/fulfilling_do.go:24	orders: fulfilling worker 0: ordering order id 29 (certificate name: galileo.bde.inp-toulouse.fr, subject: galileo.bde.inp-toulouse.fr)
certwarden  | 2025/01/28 14:24:11 [INFO] Found CNAME entry for "_acme-challenge.smtp.inpt.fr.": "acmechallenge.inpt.fr."
certwarden  | 2025-01-28T14:24:12.282Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 1 (33%, min: 100%), will check again in 12.1s
certwarden  | 2025-01-28T14:24:24.822Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 0 (0%, min: 100%), will check again in 17s
certwarden  | 2025-01-28T14:24:42.123Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 1 (33%, min: 100%), will check again in 25.6s
certwarden  | 2025-01-28T14:25:07.853Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 1 (33%, min: 100%), will check again in 25.1s
certwarden  | 2025-01-28T14:25:33.234Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 1 (33%, min: 100%), will check again in 28.9s
certwarden  | 2025-01-28T14:26:04.251Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 2 (67%, min: 100%), will check again in 43.4s
certwarden  | 2025-01-28T14:26:49.737Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 2 (67%, min: 100%), will check again in 41.4s
certwarden  | 2025-01-28T14:27:31.333Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 1 (33%, min: 100%), will check again in 46.5s
certwarden  | 2025-01-28T14:28:19.956Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 2 (67%, min: 100%), will check again in 58.1s
certwarden  | 2025-01-28T14:29:18.314Z	info	dns_checker/check_types.go:41	dns_checker: check _acme-challenge.smtp.inpt.fr: propagated: 2 (67%, min: 100%), will check again in 1m7.2s
certwarden  | 2025-01-28T14:30:33.277Z	info	challenges/solver.go:146	challenges: challenge pending status (https://acme-v02.api.letsencrypt.org/acme/chall/112651704/467511290465/1q5NRg) not a final status, will check again in 8.4s
certwarden  | 2025/01/28 14:30:41 [INFO] Found CNAME entry for "_acme-challenge.smtp.inpt.fr.": "acmechallenge.inpt.fr."
certwarden  | 2025-01-28T14:31:00.183Z	info	orders/fulfilling_do.go:216	orders: fulfilling worker 0: order id 29 completed with status valid (certificate name: galileo.bde.inp-toulouse.fr, subject: galileo.bde.inp-toulouse.fr)
certwarden  | 2025-01-28T14:31:00.355Z	info	orders/fulfilling_do.go:218	orders: fulfilling worker 0: order 29 done

@gregtwallace
Copy link
Owner

Interesting. I’m not certain that is the same exact issue.

All of those domains have CNAME records to the same singular domain?

Did you create any CNAME records just before running the attempt to generate a certificate (in particular the smtp subdomain)?

Who is your DNS provider? I might need to test more specifically with the same provider to see what might be going on.

@LeGmask
Copy link
Author

LeGmask commented Jan 28, 2025

Yes, all ours domains point to the same CNAME for acme-challenge : acmechallenge.inpt.fr..

No, all these CNAME records are pretty olds (few years I would say), I'm migrating from a standalone script that use lego cli. And it was working fine with this script.

We use the dns01goacme provider, which update our BIND9 DNS server using RFC2136. The TSIG key can only update acmechallenge.inpt.fr..

@gregtwallace gregtwallace reopened this Jan 29, 2025
@gregtwallace
Copy link
Owner

gregtwallace commented Jan 29, 2025

I'm really not totally sure what's going on in your case. The fact it didn't ever propagate in your most recent log but then worked fine on retry is really throwing me off. (edit: I guess your prior logs show that too which is sort of strange.)

I've got a couple ideas for additional checks to implement to try and properly fix this.

You may also want to try to switch to the go-acme le-go provider if it works with your DNS. That code is native Go code vs. the acme.sh script which is sort of hack-ily crammed in.

@gregtwallace
Copy link
Owner

Can you provide the full log from the failed job (from start of job through the job being complete)? For the future, please edit the config.yaml to set 'log_level': 'debug' so I can get a full debug log of the next failure.

Please also send a screenshot of how your aliases are configured:

Image

@webprofusion-chrisc
Copy link

Hi, using a single CNAME as delegation for an _acme-challenge on multiple domains is normally not practical. You are relying on sequential response so you don't clobber previous challenges, so you need to wait at least a minute after each update then submit your challenge response then move on to the next challenge response.

You may have gotten this to work with some other ACME tool in the past bu it definitely doesn't scale as you add more domains.

What you can do is CNAME each domain to it's own record, e.g. if you had an example subdomain acme.inpt.fr and you create your CNAMEs to point to records under that:
_acme-challenge.smtp.tvn7.fr CNAME _acme-challenge..smtp.tvn7 acme.inpt.fr
_acme-challenge.mailman.tvn7.fr CNAME _acme-challenge. mailman.tvn7.acme.inpt.fr

You can also use tools like acme-dns or compatible services to handle your delegated challenge response CNAMEs

@gregtwallace
Copy link
Owner

I agree the situation isn't ideal and it might not be something I can fully fix.

I do think this is worth at least a little more exploring though as I do think the challenge handling could be updated a little bit for better results for everyone (and perhaps some error messages for specific issues).

I'm already considering 1) add a CNAME record check when aliases are in use (so an error can be returned to users if their DNS records aren't correct) and 2) add a pre-check to verify the expected challenge dns name doesn't already exist prior to provisioning and to either sleep to see if the issue resolves or to abort and immediately return an error (I'm leaning toward the former and returning the latter after the issue isn't resolved after a sane timeout).

@webprofusion-chrisc
Copy link

It depends a little on your DNS providers as to whether you have fine grained control over how they work, in an ideal world you would allow a TXT record to have 2 values and discard the oldest/first value whenever you need to add a new one, that way wildcard + apex domain validation works first time without a cached validation and optionally in parallel.

For all DNS providers, adding the TXT value takes time for the values to reach all the nameservers for that domain (the CA will check some or all of them for the same answer), likewise removing it.

If you had a particularly slow DNS vendor (most are synced within 1 minute, some are up to 5 minutes) and you want to add the TXT, then wait for nameserver propagation, then get the challenge validated, then clean up the record before trying the new one then you are up to 10 minutes per domain. You can cut that by making your cleanup of the old value be a replacement instead of a removal.

As a worst case scenario if you had 100 subdomain domains it could take 8 hrs (best case 1hr 40mins) to renew that cert using sequential DNS updates to the same zone (or if working sequentially across many zones within the same cert order).

Note that in my own app that does this the approach has grown over time and can be different depending on the DNS provider being used, so I can't talk about best practises :) in an ideal world we would have one DNS API and multi-value TXT records would be easier and consistently handled, then you could validate most certs in one shot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants