caddy: v2.10.0-beta.2: ECH with domains that use wildcard certificates not work

With the config, I tested the ECH working status with curl and chromium, found that there may be some issue with the wildcard certificate working with ECH. Tested with 39262f86632401ae4915600b042ef5a28141d3d5

Here is part of the log, TLDR, all subdomains *.nyaw.xyz (that are using wildcard certificate) has ech status of not configured (even if the HTTPS record for * existed):

curl -v --ech true --doh-url https://1.1.1.1/dns-query https://matrix.nyaw.xyz

# snippet
* ECH: result: status is not configured, inner is NULL, outer is NULL
* ALPN: server accepted h2
* Server certificate:
*  subject: CN=*.nyaw.xyz
# snippet
> curl -v --ech true --doh-url https://1.1.1.1/dns-query https://yidhra.nyaw.xyz
#...
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256 / X25519MLKEM768 / id-ecPublicKey
* ECH: result: status is not configured, inner is NULL, outer is NULL
* ALPN: server accepted h2
* Server certificate:
*  subject: CN=*.nyaw.xyz

dns.google query result (no HTTPS record with ech pubkey exist, if it has, it’s I’m in debugging)

Image

The part of my config , matrix.nyaw.xyz placed in subroute of *.nyaw.xyz, and yidhra.nyaw.xyz is standalone. All of 3rd level domain has ECH status of not configured. And I set prefer_wildcard enabled.

{
  "apps": {
    "http": {
      "servers": {
        "srv0": {
          "automatic_https": {
            "prefer_wildcard": true,
            "skip_certificates": []
          },
          "routes": [
            {
              "handle": [
                {
                  "handler": "subroute",
                  "routes": [
                    {
                      // matrix.nyaw.xyz and all other domains here
                    }
                  ]
                }
              ],
              "match": [
                {
                  "host": ["*.nyaw.xyz"]
                }
              ]
            },
            {
              "handle": [
                // ..
              ],
              "match": [
                {
                  "host": ["yidhra.nyaw.xyz"],
                  "path": ["/metrics"]
                }
              ]
            },
            {
              "handle": [
                // ...
              ],
              "match": [
                {
                  "host": ["yidhra.nyaw.xyz"],
                  "path": ["/probe"]
                }
              ]
            }
          ],
          "strict_sni_host": false
        }
      }
    }
    // ...
  }
}

While I set prefer_wildcard false, after reloading, following HTTPS record newly added to cloudflare, ECH status for yidhra.nyaw.xyz turns to success. (other *.nyaw.xyz remains)

Image

> curl -v --ech true --doh-url https://1.1.1.1/dns-query https://yidhra.nyaw.xyz
* Some HTTPS RR to process
* Host yidhra.nyaw.xyz:443 was resolved.
* IPv6: (none)
* IPv4: 8.210.47.13
*   Trying 8.210.47.13:443...
* ECH: ECHConfig from DoH HTTPS RR
* ECH: imported ECHConfigList of length 69
* ALPN: curl offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256 / X25519MLKEM768 / id-ecPublicKey
* ECH: result: status is succeeded, inner is yidhra.nyaw.xyz, outer is nyaw.xyz
* ALPN: server accepted h2
* Server certificate:
*  subject: CN=*.nyaw.xyz

Originally posted by @oluceps in #6887

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 31 (13 by maintainers)

Commits related to this issue

Most upvoted comments

@oluceps Thanks, I was able to reproduce that behavior, and have pushed a fix. (We’re currently establishing more proper semantics for libdns packages, and one of them is to use “@” instead of “” in record names that are returned from the libdns functions. Right now, Cloudflare returns “” even when, in the UI, they show “@”. So I’ll need to fix that upstream, but I have a temporary fix in Caddy for the moment.)

Can you try the latest commit with a clean slate? (Ensure all the reset instructions above are followed, plus any others you might need.)

@jsarenik I believe we have addressed your concern in another issue. 👍

(We can reopen this if needed, so feel free to continue discussion.)

Not in every test, but test in OS/browsers that not ever accessed the domains before show the same result. And while testing with browser I always newly start one.

In my experience, restarting the browser isn’t enough. DNS is very persnickety and sticky. 🙂

BTW have you ever tested with curl?

I normally do test exclusively with curl or with Go programs, but in this case, I haven’t; mainly because getting curl with ECH up and running on my platform was too complicated for the time I had.

I would like to first rule out discrepancies in test results caused by differences in clients, even though the test results on the browser appear negative to me.

Fair point, and I would like to also, since I typically strongly advise against using browsers for testing, because they do all sorts of funky magic. And given the experimental nature of the tech, it’s quite possible that clients differ significantly, or have bugs.

If I have time to get curl with ECH running, I will try it; but until then, it’s still imperative that every test starts with a clean slate in every relevant way: DNS cache, TLS session, TCP connection, restarting the server process, recompiling the server binary, etc etc. (I’ve had to be very careful about that in development as well. Yes I’m sure there are easier ways, and yes I’m stubborn. 😉)

Been a bit sidetracked with some other pressing issues, but I’m returning to this one ASAP (right after the weekend, I hope). In the meantime if you make any progress, keep me posted!

@mholt wrote:

@oluceps Ah, I do see the HTTPS record now. Apparently --any doesn’t include HTTPS for some reason; but -t HTTPS does bring it up for me.

Querying ANY is disabled on many DNS servers.

$ host -t ns cloudfare.com
cloudfare.com name server fish.ns.cloudflare.com.
cloudfare.com name server wells.ns.cloudflare.com.
$ host -t any cloudfare.com fish.ns.cloudflare.com.
Using domain server:
Name: fish.ns.cloudflare.com.
Address: 108.162.194.252#53
Aliases:

cloudfare.com host information "RFC8482" ""

Some extra info about my testing envs:

Local PC:

Linux 6.13.5, NixOS, 25.05 (Warbler), 25.05.20250305.59e3cd3

Windows 11

  • Edge

VPSs in different ISP:

Linux 6.13.5, NixOS, 25.05 (Warbler), 25.05.20250305.59e3cd3


All browser had verified ech working with tls-ech.dev and nyaw.xyz. but *.nyaw.xyz wildcard ech not work.

These are doh servers used when I test:

And actually, ECH works for me, for your domains. This is me loading https://yidhra.nyaw.xyz in Firefox:

That’s because I set prefer_wildcard false at present, You could try again now since I set it to true now (and clean https record then restart caddy).

And, while setting prefer_wildcard, the ech-publish log which i previous mentiond:

Mar 12 02:10:29 yidhra caddy[53626]: {"level":"debug","ts":1741716629.598381,"logger":"tls.ech","msg":"publishing ECH config list","domains":["yidhra.nyaw.xyz","*.nyaw.xyz","api.atuin.nyaw.xyz","nyaw.xyz"],"config_ids":[64]}

Has no "yidhra.nyaw.xyz" in list. (which I think maybe expected? since it uses wildcard cert)