-
Notifications
You must be signed in to change notification settings - Fork 172
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
TLS 1.3 connection throwing Errno::ECONNRESET
#765
Comments
I reproduced the error myself. The server is actually sending an RST, aborting the TLS connection. The server (payments.cat.uk.pt-x.com:443) doesn't fully support TLS 1.3 and seems to require the workaround mentioned in https://datatracker.ietf.org/doc/html/rfc8446#appendix-D.4
Currently, you can enable the middlebox compatibility mode with
|
According to SSL_CTX_set_options(3), However, it's not enabled in net/http because Line 148 in 72d1be9
IMO it should preserve options that are set by default/by the OpenSSL configuration file. Somewhat related: #709 |
Wow, many thanks for looking into this, I was really struggling. ❤️ |
Hey @rhenium, I had one more question. I ran this to disable middlebox compatibility, and it still works
Does this mean server properly supports TLS 1.3 since it works with and without middlebox flag? I feel server's implementation of TLS 1.3 is correct. Is some server side change possible that would allow existing openssl gem version to work with TLS 1.3? I compared 1.3 and 1.2 and it seems that in TLS 1.3, we don't get a SSL session ticket (I hope this is what it's called). Is my conclusion correct? I did some more testing to see if there are any TLS 1.3 implementations that behave similarly and I found Google's API also behaves similarly. Here are some tests:
Here are the corresponding openssl tests
and for the original host
Only real difference here is Cipher and size of public key. I also did
payments.cat.uk.pt-x.com
Is this relevant somehow? This difference leads me to believe that the server may actually be misconfigured somehow but openssl managed to connect with strict TLS 1.3 connection, which doesn't support this conclusion. Could there be some deeper bug with OpenSSL gem? We could probably test further by testing with JRuby but I do not know how to override OpenSSL options when creating request via |
This doesn't work for me. As soon as I send some payload (such as "GET / HTTP/1.0\r\n\r\n"), the TCP connection is reset. This doesn't happen with the middlebox compatibility mode enabled, so it's likely the server (or some sort of load balancer/firewall in front of it) has an issue. Currently you can manually set
This is completely normal with TLS 1.3 because a server may send a new session ticket at any time. |
Amazing. I will speak to vendor to look into this. Thank you, I have learned a lot from this. |
Prerequisites
Issue
Hi, I am trying to run the following script in irb on Ruby 3.2.2. I am using OpenSSL 3.2.0. This web request works in Python and also in JRuby but is failing in CRuby. I believe it's a bug in the underlying C implementation of the openssl gem but I've hit my limit in terms of debugging it. Can anyone please investigate if it is indeed a bug or if it's a server-side implementation quirk?
This gives me
on all my machines. Setting min and max version to TLS 1.2, however, works on all installed Ruby versions and all machines.
I checked JRuby's ruby interface of the openssl gem, and it seems to be a nearly identical copy. I tried using their
buffering.rb
in lieu of this one, but I ran into the same connection reset issue. If I were to hazard a guess, thesysread_nonblock
implementation behavior differs here in this gem's implementation vs the JRuby implementation, which leads to the difference in behavior. I've also attached a pcap file of the call when I attempt it through Ruby, and it resets. I don't see any obvious issues but I am no network expert.(TIL GitHub doesn't like pcap so it's attached as a tar 🤷♂️)
tls13github.tar.gz
The text was updated successfully, but these errors were encountered: