HTTP-01 challenge is tried using https first

The root of the problem here is that you are looking for a bug in Let's Encrypts http domain validation, but you need to look for a bug in your own http response. The chance of it being a bug in Let's Encrypt is not zero, but the chance of it being a bug in your config is 99.999% or thereabouts.

LE will resolve your domain to a set of IPs and it will try some of them as http, with a preference for IPv6. It will do this from multiple geographic locations. If any of those IPs that it tries then respond with a redirect then it will follow them. If on the other hand the IP it tried blocks http on TCP port 80 that's where it will stop (and you'll get nothing in your nginx log).

Own the problem and commit to the idea that it's your own config that's getting in the way, you'll get this fixed.

@jean-christophe-manc I ran a test that reproduces your failed validation exactly. Even to include the IPv4 address wrongly shown with HTTPS (that is a known bug as I said).

And, the situation is exactly as I described earlier:

  • I have both A and AAAA record for domain
  • IPv6 inbound to my server is blocked by firewall rule
  • My nginx redirects HTTP to HTTPS for all requests (even acme challenge)

This results in the same sequence in the Validation Record as I described most recently in post #21 :

  • LE tried HTTP to IPv6 but times out (in this test b/c of firewall)
  • LE retries HTTP to IPv4 and gets redirected to HTTPS
  • LE follows redirect using IPv6 and times out again
  • It does not retry IPv4 after redirect so challenge fails.

You really need to study your infrastructure. And, you need to get away from thinking that LE sends multiple simultaneous HTTP requests to each IP address. It does not. An HTTP Challenge is a sequential series of http(s) requests.

With this in mind, you still have not explained how you plan to have both of your IPv6 addresses reply correctly. LE may choose either one. And, each must be able to reply correctly. Which may involve a carefully crafted redirect. But still must result in a satisfied challenge.

Hence my earlier question "Could you give me the IPv6/IPv4 addresses of the server(s) validating the challenge?" Even a range would have been helpful to rule this out or not.

Mine did not.

That could not have happened in my case.

I know mine perfectly. Do you know where LE challenge servers are located? Do they answer in the same region/country as the challenge source?

When/where did I write that?

I have already answered that. Please read my answers carefully.

As a conclusion, considering that there was no http --> https redirect on my side, and that all my IPv6/IPv4 addresses were operational (except for the first test), we can state that the cause of that issue comes from either:

  • LE IPv6 and IPv4 addresses blocked by my firewalll which is unlikely if LE challenge servers answer in the same region/country as mine
  • or an unidentified issue on LE side

I know that because I have already successfully validated an LE challenge for the same server FQDN a few months back with the same challenge type http-01... with the exact same workflow on my side as the one that was used to trigger the current issue:

account_uri: https://acme-v02.api.letsencrypt.org/acme/acct/417325880
authorizations:
  sdx1-kvm.sdxlive.com:
    challenges:
    - status: valid
      token: token
      type: http-01
      url: https://acme-v02.api.letsencrypt.org/acme/chall-v3/333279173307/zLG-mA
      validated: '2024-04-01T13:17:06Z'
      validationRecord:
      - addressUsed: 2a01:e0a:81c:99c0:558c:7a:5b5c:7b5d
        addressesResolved:
        - 82.66.198.137
        - 2a01:e0a:81c:99c0:558c:7a:5b5c:7b5d
        hostname: sdx1-kvm.sdxlive.com
        port: '80'
        resolverAddrs:
        - A:10.1.12.85:30182
        - AAAA:10.1.12.81:31390
        url: http://sdx1-kvm.sdxlive.com/.well-known/acme-challenge/token
    expires: '2024-05-01T13:17:07Z'
    identifier:
      type: dns
      value: sdx1-kvm.sdxlive.com
    status: valid
    uri: https://acme-v02.api.letsencrypt.org/acme/authz-v3/333279173307
cert_days: 89
challenge_data: {}
challenge_data_dns: {}
changed: true
failed: false
finalize_uri: https://acme-v02.api.letsencrypt.org/acme/finalize/417325880/257230646757
order_uri: https://acme-v02.api.letsencrypt.org/acme/order/417325880/257230646757

Anyway, I have moved on to dns-01 challenge which worked fine:

account_uri: https://acme-v02.api.letsencrypt.org/acme/acct/id
authorizations:
  sdx1-kvm.sdxlive.com:
    challenges:
    - status: valid
      token: token
      type: dns-01
      url: https://acme-v02.api.letsencrypt.org/acme/chall/id/id2/id3
      validated: '2024-11-22T15:12:04Z'
      validationRecord:
      - hostname: sdx1-kvm.sdxlive.com
    expires: '2024-12-22T15:12:06Z'
    identifier:
      type: dns
      value: sdx1-kvm.sdxlive.com
    status: valid
    uri: https://acme-v02.api.letsencrypt.org/acme/authz/id/id2
cert_days: 89
challenge_data: {}
challenge_data_dns: {}
changed: true
failed: false
finalize_uri: https://acme-v02.api.letsencrypt.org/acme/finalize/id/id4
order_uri: https://acme-v02.api.letsencrypt.org/acme/order/id/id4

This is for the best. The HTTP-01 challenge is already proven to be incompatible with your preferred strict firewall policy. The link below goes to the relevant FAQ topic on the IP addresses used for validation.

I just want to note that I have received an HTTPS redirect for all the http urls listed above.

Whenever debugging this sort of stuff, i like to use curl -I and I will try from my local machine, then confirm the same behavior with a few different cloud/remote server accounts I have. The reason for this is that there are sometimes geographic routing issues or networking/firewall rules that someone in place.

Jonathans-MacBook:~ jvanasco$ curl -I http://sd1-kvm.sdxlive.com/.well-known/acme-challenge/Test404
HTTP/1.1 301 Moved Permanently
Date: Fri, 22 Nov 2024 22:20:29 GMT
Content-Type: text/html
Content-Length: 162
Connection: keep-alive
Location: https://sd1-kvm.sdxlive.com/.well-known/acme-challenge/Test404
Content-Security-Policy: default-src 'self'; frame-ancestors 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src https://sdxlive.com;
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block

Jonathans-MacBook:~ jvanasco$ curl -I http://sdx1-kvm.sdxlive.com/test.txt
HTTP/1.1 301 Moved Permanently
Date: Fri, 22 Nov 2024 22:21:59 GMT
Content-Type: text/html
Content-Length: 162
Connection: keep-alive
Location: https://sdx1-kvm.sdxlive.com/test.txt
Content-Security-Policy: default-src 'self'; frame-ancestors 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src https://sdxlive.com;
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block