-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
Recent BearSSL updates not honoring client.setInsecure() for Public WiFi that requires acceptance of "Terms and Conditions" at redirected address #5019
Comments
@gojimmypi your linked code is too long. Please reduce to a MCVE sketch for testing. |
ok, will do. I'm having some difficulty in coming up with a tiny demo that shows the problem, as once I am connected with working code, the AP allows me to reconnect for quite some time, no longer redirecting to the terms and conditions page. Please be patient and I will supply an example as soon as I can. in the meantime for reference - the breaking code is in commit f776454 |
The traveling today so can't get into details, but the referenced commit doesn't affect anything but a newline to the serial port. Can you check that's the right one? SetInsecure just disables the SSL checking. It always returns OK when asked by the backed. There is no concept of a redirect at the tcp level, only at the https one. You need to be able to negotiate a SSL connection and then handle the http protocol and the returned 301 (or whatever the permanent or temporary redirect code is...) A reproducible sketch would help explain what you're trying to do... |
@earlephilhower I should have been more clear; the working code is 7dd2ca3 - somewhere between there and f776454 a change was made to cause |
Ah, that would make more sense, @gojimmypi. Just to be clear, We'll follow up when you get some time after the 20th. Thx |
@earlephilhower could you please clarify:
when attempting to connect to a valid TLS server with a current certificate and all... what would you expect to happen if the "terms and conditions" web server on the AP inserted itself to show that page before proceeding? I would think that the page would be flagged as "not secured", no? That would essentially be acting as MITM (thus why I thought if it is not related to the thanks for feedback, I'm certainly curious as to the cause and solution here. |
@gojimmypi I think you're saying the AP is serving fake DNS response with a short TTL so that, say, www.github.com points to 10.0.0.1 or whatever the portal is, yes? Or are you saying it does a redirect, which is a HTTP-level thing and not at the TCP stack level? If www.site.com DNS resolves to 10.0.0.1, then the SSL object will try and open a TCP connection to 10.0.0.1:443 and begin the TLS handshake. As long as the AP on that port handles TLS negotiation and sends back any certificate, (i.e. one valid for 10.0.0.1 and not www.site.com) it should work. If the AP doesn't have a https login page, though, it won't connect since it can not fallback to :80 un-encrypted comms. If that's the case, I'll need some wire dumps to see what's going on. I don't have any way to reproduce it otherwise except when I'm stuck in a hotel. While I like the 8266 and its quirks, I don't like it enough to bring it on business trips. :) |
One other thing, the setInsecure does not live through connect attempts. That was an API change before the release where each connection reuse was set to "start fresh." So, if you're only doing setInsecure one time at the start of the app, just move it to right before the connect() line and you may be all set. |
@earlephilhower interesting questions: no, I didn't think that fake DNS is being used (although indeed I suppose that would be one way to implement that). I'm thinking that this is purely a redirect; I recall when the new 1.1.1.1 dns came out, I was wondering what would happen to my code (that was the old location of the AP pseudo web server). Indeed the IT folks ended up changing the AP software, breaking my code, and now the address is http://192.0.2.1 see: https://github.com/gojimmypi/DesktopDashboard/blob/development/htmlHelper.cpp#L744 and here'e where I manually do the get/redirect (but on port 80, now making me wonder if this new problem is at all related the TLS): https://github.com/gojimmypi/DesktopDashboard/blob/development/htmlHelper.cpp#L797 (Admittedly this is quite a hack, but I learned a lot; I definitely need to clean up the code) I think this is the most promising comment:
As yes, I believe I set it only once on the object at init time. Unfortunately I don't have access to this from home, but I am looking forward to exploring it more. I'm not sure I'll be able to provide any wire dumps, as I don't have access to the AP, and I certainly don't have WireShark for the ESP8266 ;) I did play with this AP packet forwarder: https://gojimmypi.blogspot.com/2017/08/openwrt-remote-network-wireshark-packet.html but alas this would the forwarding router AP itself to be a client - and I'd lose the actual ESP8266/BearSSL-AP packet exchange. Do you have any tips on how to sniff these packets, other than in my own code? stuck at a hotel, eh? Hopefully you've been enjoying DefCon! |
Can you please simplify what you're doing and where it fails into a small MCVE? I've looked over bits of the code and, from the descriptions I don't even see any SSL connections in the I'm not sure what the comparison with It's always safe to setInsecure() on the client, and takes no time (sets 1 flag and returns), so you can move that down unconditionally right before the W/o the MCVE, though I'm not sure there's much we can help with here. If you can't control the AP, then you probably can't get a good packet trace. But at this point, I'd recommend making a MCVE to pinpoint the problem, which could very well be elsewhere... |
Just a heads up that the sprinkling of more
This is half-baked code that will eventually pass a pointer to a client object in a helper-class wrapper.
lol - that is actually a critical piece of code, without it the captcha gets triggered. Thanks for your patience as I've not yet had time for the MCVE. |
Check PR #5120 . The connection flags got stomped on in some cases which may have caused |
Hm. Yes, #5120 is interesting and similar, however I'm not sure that's my exact problem. Even when using I've created a mini sample (not quite ready to call it an MCVE)... but at least it is vastly simpler: https://github.com/gojimmypi/MCVE_5019 The Code works fine with my AP without a guest prompt redirection. I'll need to make some time soon at the day job to see if I can narrow this down any more. Any suggestions as to |
@earlephilhower I finally discovered the problem with
See tools/sdk/include/bearssl/bearssl_x509.h for all the BR_ERR codes Compounding my problem is the fact that not only does my device not have a power-loss-tolerant RTC, but our internal network does not allow outbound ntp traffic. (see also #1679); there may also be issues with timezone (see #4637) I've confirmed the cert date validation despite I've updated my MCVE on this topic, and here's some time-setting code in case someone runs into a similar time problem:
Edit: Added code comments to
(although I am curious if it will actually work properly when time changes later in the year) |
Basic Infos
Platform
Settings in IDE
Problem Description
Hello.
Recent updates (since June 13) have apparently disabled or otherwise now ignore the
(BearSSL::WiFiClientSecure)client.setInsecure()
to no longer allow an "insecure" connection. Fortunately I had a backup of my \hardware\esp8266com\esp8266 to confirm this.So why would one want to allow an insecure connection? Well, when you are connecting to a Public WiFi access point that asks to "accept the terms and conditions" of use. (It's our own WiFi, in a corporate environment). When doing a
client.connect(host, httpPort)
over SSL, the connection simply now fails. I suspect the problem is I'm trying to connect to a "real" TLS/SSL address, and the WiFi sneaks in and forces the "response" to instead come from 192.0.2.1 (a pseudo web server of sorts at the AP)- the nature of SSL under normal conditions, is that yes - it failed. But during intial connection time, I'm actually expecting this. (and it recently worked)If interested in the details, I have a doAcceptTermsAndConditions() in my development branch:
https://github.com/gojimmypi/DesktopDashboard/blob/development/htmlHelper.cpp#L722
The text was updated successfully, but these errors were encountered: