-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
rustls refuses to establish connections to self signed TLS certificates #10312
Comments
Analysis so far: CA cert is being added to rustls here: Lines 497 to 498 in 21ab4d9
Error originates at https://github.com/briansmith/webpki/blob/e51f215d2ea45940d98db21b24f3a8be02f7606d/src/verify_cert.rs#L55 Cert doesnt actually end up in webpki trust anchors list. Don't know why. |
Multiple copies of webpki/webpki-roots? |
Nope |
webpki 0.21.4 doesn't like the ca cert. It looks like either |
Ah great... so I guess this should be reported upstream? OpenSSL can do it, so I think rustls should too. Thanks for digging into this. |
I've opened briansmith/webpki#226 with a failing regression test, to solicit feedback. |
There's a workaround: apply this patch and regenerate the certificates with diff --git a/tools/wptserve/wptserve/sslutils/openssl.py b/tools/wptserve/wptserve/sslutils/openssl.py
index 87a8cc9cc7..bbf500d8ca 100644
--- a/tools/wptserve/wptserve/sslutils/openssl.py
+++ b/tools/wptserve/wptserve/sslutils/openssl.py
@@ -216,7 +216,7 @@ basicConstraints = CA:true
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer:always
keyUsage = keyCertSign
-%(constraints_line)s
+#%(constraints_line)s
""" % {"root_dir": root_dir,
"san_line": san_line,
"duration": duration, web-platform-tests/wpt#11075 indicates the |
Turns out it was indeed a webpki bug. Submitted a fix. |
Don't emit nameConstraints when generating certificates, webpki can't parse them. Fixes denoland/deno#10312.
I'm going to reopen this, as the root issue has not been resolved. We only mitigated it for the specific usecase it was causing an issue. |
I think I'm running into this with a Postgres DB.
But a ca cert is provided like so:
Does a provided ca cert still need a valid issuer? Because then the |
No it doesn't need to be valid, but the CA cert and the leaf cert used for TLS may not be the same thing. I will take a look to see if there are any misconfigurations in our TLS ops. |
@lucacasonato do you have a reproducible example already? I wouldn't want you to waste time. I have a pg server that I hit this issue with but I definitely can't rule out the certificate having issues somehow. The more I dive into this the more I'm .. 'impressed' 😅 , with the complexity of TLS. Besides, I've moved on to a different hosting provider that lets me make unsecured private connections to the DB. It offers secured with self-signed cert too, but only with an IP (Google Cloud) and that seems to be unsupported by rustls. If I can help by providing a server and cert for example you can reach me at https://t.me/cryptogohan |
Don't know if it helps a lot but having the same issue as @cryptogohan with a Postgres database in Heroku, both locally and in the prod deploy over heroku. |
Don't emit nameConstraints when generating certificates, webpki can't parse them. Fixes denoland/deno#10312.
still not fixed, so reopening |
Hmm, I think I can step-out here. For my case it seems self-signed certificates are working fine, I've managed to narrow down the issues to different things. There is the Digital Ocean case I discuss over here that hits a |
There was a change made in this area recently, in addition to adding support for loading certs from the certificate store it also did a bit of refactoring which unified a couple places in code to all call a common function. It may be worth trying again with the latest version (when it lands with this change, or build from main) and see if it still reproduces. |
@lucacasonato can this be closed given that |
No, this specific case is a bug in rustls/webpki (briansmith/webpki#226) |
Just for general information. I was able to get rustls to work with a self-signed certificate building things from the shell script found in https://stackoverflow.com/questions/76049656/unexpected-notvalidforname-with-rusts-tonic-with-tls The server side was PostgreSQL, not rustls, so this may not at all be relevant. |
Reproduction
The key chain this uses is made up of two parts. The CA (
./test_util/wpt/tools/certs/cacert.pem
) and the end entity certificate (./test_util/wpt/tools/certs/web-platform.test.pem).To start the testing server:
deno run -A --unstable ./tools/wpt.ts setup cd ./test_util/wpt ./wpt serve
See that
curl
ing the endpoint with the correct CA cert in the roots works, and without doesn't:See that it doesn't work with Deno in any configuration:
This same issue is reproducible with
WebSocket
, but for now lets only usefetch
because it is easier to test with.The text was updated successfully, but these errors were encountered: