caddy: http.request.tls.client.* placeholder broken for Caddy 2.6.3+
Let me first say thanks for this awesome product ! The bug I am about to “complain” is rather a first world problem^^
I am using following matcher to decide whenever I am on a “safe” client (with installed client certificate) or some “public” machine (fallback to Authelia):
@missing_mTLS_cert {
expression {tls_client_subject} == null
}
forward_auth @missing_mTLS_cert ... {
....
}
Everything was working fine until 2.6.3 … Starting from this version it become unstable… Now even with a valid certificate it randomly fails (placeholder not set (?)). forcing me to login with Authelia …
Thanks!
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 37 (20 by maintainers)
I’m unable to replicate this. Just to confirm, are we using some version of Caddy other than 2.7.6? E.g., given this Dockerfile, should I get the same version of Quic as you?
Thanks for the details! I’ll try to circle back to this soon! Got just about 80 notifications in my backlog still… 😅
Hi folks, I got very good progress and I am able to consistently replicate the issue with Curl and Caddy 2.7.6. Thanks to @francislavoie for linking to HTTP3 version of Curl in the thread here.
It seems the issue always occurs in HTTP3/QUIC. It does not occur over HTTP1 or HTTP2. Previously, I stated “[i]t seems to only occur with browsers (Firefox, Chrome) and only sometimes.” This is false, wrong and absolute misinformation. The only reason why it occurs “sometimes” is because Firefox and Chrome tend to switch between HTTP2 and HTTP3 seemingly in a random fashion. I’m not quite sure what gets them to switch between the two, but I reckon that’s out of scope of this issue.
I can confirm that this behavior is always consistent, given the variables below.
Given the following Caddyfile:
and the following Docker Compose file:
Where “Cloudflare_Caddy” is simply Caddy with the official Cloudflare module, the following curl command:
Will always generate the following reverse proxy request, taken from the Caddy log:
I used a simple Python program written by ChatGPT to send back the HTTP headers, and I can confirm they match the log (meaning the client certificate is never passed to backend).
If, however, you disable HTTP3 via
servers{protocols h1 h2}, the client certificate is passed normally:Attached here certificates.zip are the intermediate CA, client certificate and associated key files for ease of testing. The file client.p12 is provided in case either of you want to test a web browser, both Chrome and Firefox only support P12 files to the best of my knowledge. The certificate keys are plaintext. The certificates and associated keys were generated with the following commands, using Smallstep CLI:
Please let me know if you need any more information, and again, my apologies for the wait.
No rush 😃
@mholt
😦 I have not. Let me try to work this sometime this week. Sorry again for the delay.
Dear all:
Thank you all for this thread. For me, the issue is that I was using
{http.request.tls.client.certificate}instead of{http.request.tls.client.certificate_der_base64}.So thank you for your time, @mholt
Greetings and best wishes!
Yeah long story, I used a mod by someone in a different issue to get around this since Caddy doesn’t wrap certs in escape characters–it was unrelated to the issue so I didn’t want to bog down my already-wordy paragraphs with extraneous details.
This is a lack of an understanding of how curl processes the
--nextrequest on my side then.Let’s put a pin in this for now. I will do more testing on my side and see if I can recreate the issue I am having in the web browsers I tested with curl, instead. The workaround for now is to disable HTTP3, which allows users to successfully use require_and_verify. I will also see if this behavior occurs with other web servers (Nginx, Apache, etc.) to see if it’s an issue that is only related to web browsers.
I think the issue should be left as open with needs info. I will update as soon as I can, likely after Hacker Summer Camp. Sorry for the delays on my end.
ALCON,
I am having the same issue where Caddy v2.6.4 only sometimes passes the client certificate to the backend server (in my case, Keycloak, but it shouldn’t matter whether it’s Keycloak, Authelia, or Authentik). Note that this issue only occurs if H3 is enabled and
verify_if_givenis used. Ifrequire_and_verifyis used, this issue doesn’t occur. Below is my CaddyfileAttached here is my debug log. Note that I removed the following from the logs, do let me know if it is an issue:
Another difference is I cannot recreate the issue with curl. It seems to only occur with browsers (Firefox, Chrome) and only sometimes. I know this is unhelpful. I will also try the latest alpha version, as well, and comment here.
@francislavoie You are right! I don’t see any http3 requests when testing with 2.6.2.
The behavior changed with 2.6.3+
Hmm. So you’re saying it seems broken for H3 requests but it works fine for H1/H2? Okay. Are you sure it worked with H3 with prior versions? I’m trying to understand what you’re actually describing as broken and when.
Please try v2.7.0-beta.1, we’ve made a lot of changes since 2.6.4, some of which may have already fixed it.