Traefik and Cloudflare unable to obtain certificate

Setting up a new Traefik instance, getting an error I have never seen and I am a bit confused.

time="2022-02-16T21:48:20Z" level=error msg="Unable to obtain ACME certificate for domains \"cloud.grillgeek.se\": unable to generate a certificate for the domains [cloud.grillgeek.se]: error: one or more domains had a problem:\n[cloud.grillgeek.se] [cloud.grillgeek.se] acme: error presenting token: cloudflare: failed to create TXT record: HTTP status 403: Authentication error (10000)\n" ACME CA="https://acme-v02.api.letsencrypt.org/directory" providerName=cloudflare.acme routerName=nextcloud-https@docker rule="Host(`cloud.grillgeek.se`)"
time="2022-02-16T21:48:21Z" level=error msg="Unable to obtain ACME certificate for domains \"start.grillgeek.se\": unable to generate a certificate for the domains [start.grillgeek.se]: error: one or more domains had a problem:\n[start.grillgeek.se] [start.grillgeek.se] acme: error presenting token: cloudflare: failed to create TXT record: HTTP status 403: Authentication error (10000)\n" routerName=heimdall-https@docker rule="Host(`start.grillgeek.se`)" ACME CA="https://acme-v02.api.letsencrypt.org/directory" providerName=cloudflare.acme time="2022-02-16T21:48:20Z" level=error msg="Unable to obtain ACME certificate for domains \"cloud.domain.io\": unable to generate a certificate for the domains [cloud.domain.io]: error: one or more domains had a problem:\n[cloud.domain.io] [cloud.domain.io] acme: error presenting token: cloudflare: failed to create TXT record: HTTP status 403: Authentication error (10000)\n" ACME CA="https://acme-v02.api.letsencrypt.org/directory" providerName=cloudflare.acme routerName=nextcloud-https@docker rule="Host(`cloud.domain.io`)"

time="2022-02-16T21:48:21Z" level=error msg="Unable to obtain ACME certificate for domains \"start.domain.io\": unable to generate a certificate for the domains [start.domain.io]: error: one or more domains had a problem:\n[start.domain.io] [start.domain.io] acme: error presenting token: cloudflare: failed to create TXT record: HTTP status 403: Authentication error (10000)\n" routerName=heimdall-https@docker rule="Host(`start.domain.io`)" ACME CA="https://acme-v02.api.letsencrypt.org/directory" providerName=cloudflare.acme

I have double and tripple checked and tested the cloudflare token, and it works.
Here is my setup:

Things is, even with these errors in the docker logs, I can visit start (heimdall docker), traefikdash and cloud (nextcloud docker).
I have tried so many different angels and solutions I guess I have gone blind.
So please tell me what I have missed. :slight_smile:

Hello @macmattias,

It seems that traefik cannot connect to Cloudflare. Did you have any issue in setting the corresponding configuration (e.g. CF_API_EMAIL, CF_API_KEY or CF_DNS_API_TOKEN, [CF_ZONE_API_TOKEN])?

No, when you create a token you get a curl-string to test it, and I did and it worked.
I got no issues with the internet or anything the only thing that might be an issue but still not is that my internal DNS is using Unbound.

Then, this might be a Cloudflare token issue. Check out this documentation of lego that can help you with Cloudflare token : Cloudflare :: Let’s Encrypt client and ACME library written in Go.

Does the CloudFlare token that has been created have permission to add DNS entries to the zone? As a workaround, you can try to use GlobalToken and see if the issue still exists. Then you can create the token with appropriate permission to add DNS entries to your domains.

1 Like

I checked my docker-compose and it seems I have used my Global API Token.
I get the same errors using a token setup to be able to edit my dns.

I did some research and I found that if you use API keys ( CF_API_EMAIL and CF_API_KEY ), the Global API Key needs to be used, not the Origin CA Key. however, there are also some limitations regarding the DDNS update for some TLD's. Maybe that will help to explain that specific behavior:

https://go-acme.github.io/lego/dns/cloudflare/

This worked without any issues like this before the server hosting all this crashed and I am rebuilding everything from scratch. (Backups? I was a victim of the Proxmox 7 backup bug...)
The only thing that has changed is that I have removed a ddns docker image and let pfSense take care of that instead.
I did use the Global API token. Just now I tried to set static ip and added 1.1.1.1 and 1.1.1.2 as DNS servers, no different same error still.

Now I created a new token, tested it with success added it to Traefik, after a down and up no errors.

Congrats! So the root cause of the issue was an invalid CF token.

Thanks for you update :wink:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.