-
Notifications
You must be signed in to change notification settings - Fork 13.3k
ESP8266 WiFiClientSecure connection drops immediately on GET, error not decoded #7678
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
Comments
Please enable full SSL debugging in the menu and capture the output. It's pretty chatty and may point to the exact issue in the logs. |
Also, if you're really on core 2.6.2, can you please upgrade to the latest release, 2.7.4. It should be available thru the normal channels and has quite a few bugfixes from 2.6.x. |
I'll give it a try; 2.6.2 is the newest core that's available through platformio.
Thanks again! |
Looks like it connects and then the other end times out. Are you running at 160MHZ? OTW, the SSL handshake may take too long and GOOG will drop the connection. |
Also, if 2.6.2 is really the latest PIO release we need to figure out why that is and fix it...2.7.x came out months ago. |
I'm running at 160MHz and I don't think it's that sort of problem because I can connect to many other sites (google, yahoo, etc.). My site isn't just broken because I can connect to it with browsers and from the CLI with openssl. As you suggest, the disconnect is instant once the server receives the full GET request. If I hold off on sending the final \r\n, it will keep the connection open until it receives it, but then the disconnect is instant before any response is received. |
I'm not sure what the exact error is w/SSL, but from a quick glance I see that when bit 8 is set (256) then BSSL is saying the remote side sent a SSL fatal alert: If it's your own site, can you enable debugging on the webserver and see if there's anything in the logs. Once the SSL handshake finishes ( Another thing we can add is HTTP client debugging (you can just enable everything in the debug menu) which would verify that it's not a HTTP-level issue vs. a SSL one. |
Good eyes! I saw the error codes but they appeared to be an enum rather than a bitmap and I didn't look closely enough; the 256 is added to the error code. Unfortunately that still leaves me with an error code of 40 which is also un-mapped. I'm sorry for the dumb question, you've mentioned the debug menu several times, and I've spent quite a bit of time looking for it, can you give me a pointer? From what I've seen, all debugging in PlatformIO is enabled by build flag defines in platformio.ini |
From the apache error log:
I think this suggests a problem with incompatible cipher suites...I'll dig into that. |
I think that's your culprit. SSL3 was deprecated many years ago because it was busted: https://tools.ietf.org/html/rfc7568 . BearSSL doesn't support it, either. If that's the case and your server is still configured to try SSLv3, this is expected behavior... |
BearSSL has never had SSL3 support, and it can't negotiate it ever. It was written well after the SSL3 deprecation. So if your apache isn't configured to use it, then maybe it's a false lead. I think it's time to start digging thru the BSSL sources https://bearssl.org/gitweb/?p=BearSSL;a=summary and see where the undocumented error level Also, if you have wireshark, it's quick work to verify the actual TLS level and cipher used with it, just for sanity's sake. I don't think it can decode anything to do w/renegotiations, though. |
There is an error code 40: BR_ERR_X509_EXTRA_ELEMENT (Decoding error: extraneous element.) |
Note that in WiFiClientSecureBearSSL.cpp, method getLastSSLError() should probably handle the 256 and 512 values that can apparently be added to other error enumeration codes. |
Agreed about the errors. I didn't think of looking in the X509 decoder, either. So that would lead me to believe there's something fishy with the cert exchange. I'm a little fuzzy on multi-tenant SSL, is your server shared with multiple SNI names (hence the initial handshake and then another handshake)? |
I've submitted query to Thomas Pornin (author of BearSSL) to see if he has any ideas; I dug around in the X509 code, but it is not for the faint of heart. |
I seem to have solved the issue. In my apache ssl configuration, when I moved the following two lines out of the Directory sections and into the global (VirtualHost) section, the renegotiation handshake failure stopped and my HTTP requests were processed properly.
|
Partial fix to esp8266#7678
Basic Infos
Platform
Settings in IDE
Problem Description
I am experiencing a problem with the ESP8266 WiFiClientSecure where it connects to my site, but drops the connection the moment the GET request is sent. The exact same code will work for other sites (e.g. www.google.com/index.html) but not this specific site. I have tested using fingerprint, trusted root certificate, and inscure modes; all have the same result: successful SSL connection, but connection lost the moment any HTTP GET is sent. The site works properly when tested with openssl (openssl s_client -crlf -connect mysite.com:443) or from any browser.
The SSL error returned (296) is not decoded successfully so debugging is difficult. Any guidance would be appreciated; the site is open so you can issue the Additional error handling is requested to provide useful feedback as to why a connection is dropped. More documentation will help too (I will be happy to write it once this is solved).
MCVE Sketch
Debug Messages
The text was updated successfully, but these errors were encountered: