-
Notifications
You must be signed in to change notification settings - Fork 13.3k
WiFiClientSecure doesn't handle large certificates #1816
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
enable the debug out for Core + WiFi then you will see if the resolve is the problem. Note: for http/https existing a class then you not need to handle the header and encoding yourself |
@Links2004 thank you for the second link. 👍 I'll take a look. Sorry I'm new to all this.. :/ Also debug menu is not available in the IDE if you have NodeMCU board selected and I don't have a bare esp. edit: I tried the the HttpClient method with a link in my google calendar (my private link that allows to donwload the ical) which is https://calendar.google.com/calendar/..........
edit2: ok I enabled debug
|
the generic board work with all board you only need to set the settings for flash and reset method right. but |
It's more likely that connection is failing during ssl handshake due to the certificate size. I do have a patch for this, maybe will push it on the weekend. |
I set debug to Core + WiFi
something noticed is that IP of calendar.google.com returned is 193.92.133.45 which is while calendar.google.com is also fingerprint changed from what it was yesterday (given from https://www.grc.com/fingerprints.htm) here is the info with the fingerprint
|
@igrr you mentioned you have a patch for this; I would be interested in trying it if it is in a usable state. If it is a work in progress I would still be interested in seeing how you are planning on addressing it. |
Fix issue with handling of large certificates (#1816)
This issue should be resolved with c8a1507. |
Ok the boards manager told me there's an update (v2.2.0) for esp8266 so I updated that. @igrr is the patch included in this version? I then tried @nikant's script. This is what I get. Is this "working"? Sorry I am very new to using esp8266 and ssl in general. (Using ESP-01)
|
@nikant Were you using esp8266 with nodemcu installed on it, through Arduino IDE? Is that possible? |
Well the connection was established, and server replied with 301 code, so yes, this seems to be working. There still is an issue with |
@igrr Well it initially connects, but you cannot actually do anything useful. I generated a new fingerprint from "grc.com", which is different, but I get the same error as above. One thing I wanted to ask, which you may know the answer to: If you try using Hurl to make https requests to, say, a Google Apps script that you've written, which has a doGet() function, it works perfectly. However, if you set the "follow redirects" to OFF on that website, it'll do the initial connection and then report the same error. (something like "moved") and not hit your google script's doGet(). Google seems to be redirecting the requests to "script.googleusercontent.com/macros...". Is the "follow redirects" some kind of a flag that can be included in the header for esp8266 to make it work? Or is it more complex than that. Example below. ==== Google Sheet The script has a simple doGet() like this:
The script is active. All it needs is a single parameter "value" and it should put that into the first cell. This is the syntax to be used: If you put this into hurl and run it'll work as long as "follow redirects" is set to ON. |
to my understanding the problem is that big companies like Google use multiple servers for the same domain name (load balancing, caching etc.) so one domain doesn't have one IP only and thus not one specific certificate. |
@nikant Right. Apart from the certificate error, I think that it's the inability to follow redirects, which is causing it to make the initial connection, but not do what is needed. Someone will more knowledge on this would hopefully chip in. I say this because the exact behaviour can be simulated using the hurl.it service, AFAICS. |
@igrr and @nikant This page outlines how to handle redirects: python-urllib2. It says that 'urllib2' automatically handles the redirect using the Location: header info in the data returned by the server. Is this something that can be implemented on the esp8266? |
@igrr and @nikant Ok, some success:) I am able to get the partial response and have my data passed on as a variable be posted to Google Sheets. This is the partial response, which contains the 'location' field in the header that needs to be followed, to get the final response. Any ideas how to proceed with parsing this, getting the 'location' URL and following that? |
@igrr and @nikant ok, success :) I am able to use esp8226 to make the initial request to Google, get the redirect location and make the second request to the redirected URL, getting the final response. Thanks for your help! With this, I can directly post data into Google spreadsheets and read sheet information. |
@electronicsguy hi! great! do you have a sample code for that? |
@nikant Yes of course I'll put it up. |
@nikant Code and example posted here: HTTPSRedirect. You can write/read to google spreadsheets, fetch calendar events for the next 1 week and do a google 'chat' with the ESP8266. I also fixed the certificate mismatch problem. I generate the fingerprint using openssl as described in the library. |
@electronicsguy, I've been using your code for a while now. Sometimes there was a certificate missmatch, but that could be because I'm redirected to a different server. But now I can't get it working. I'm using the openssl as you suggested, but I can't get it running anymore. Does anybody has the same issue? |
hi David
when you say it doesn't work anymore, what happens exactly? does only
certificate verification fail or also the actual reading/writing ṭo google
sheets fail? if so what is the error message? some people have reported
problems due to their specific DNS config. Could you try on a different
network and check?
…On Tue, Dec 20, 2016 at 8:07 PM, David Truyens ***@***.***> wrote:
@electronicsguy <https://github.com/electronicsguy>, I've been using your
code for a while now. Sometimes there was a certificate missmatch, but that
could be because I'm redirected to a different server.
But now I can't get it working. I'm using the openssl as you suggested,
but I can't get it running anymore. Does anybody has the same issue?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1816 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFh9vVbYEd3X9p_BB3vMb5Ns2iRHNg2cks5rJ-g0gaJpZM4H4ocE>
.
|
Hi Sujay, I couldn't even connect to the google script host anymore. But now it works again... i got rid of the certificate as it works well without them (is it right that you only need that if you do a get post?). I guess it could be something with my network. Didn't had the chance to test it on another network yet.. |
@DavidTruyens You only need certificate check for security purposes. (in case you want to make sure you're not subjected to say a MITM attack). However, Google seems to keep changing their server fingerprint by time and location, so it's hard to keep up with it. In case it's a non-issue for you, you could disregard the fingerprint check. Please let me know if things still stop working. Also try on a different network if you get the chance. |
@electronicsguy //const char* fingerprint = "F0 5C 74 77 3F 6B 25 D7 3B 66 4D 43 2F 7E BC 5B E9 28 86 AD"; fingerprint3 must be the latest but it didn't work.. I got this from https://www.grc.com/fingerprints.htm debug with your example https://github.com/electronicsguy/ESP8266/tree/master/HTTPSRedirect
This fp works, i got this from debug so how can i use it when my const char* fingerprint is wrong? |
@electronicsguy loving your work Sujay.
|
OK I found the correct fingerprints for Google in our part of the world (edge of Europe / Asia).
Serial Monitor now states "Certificate match." |
@kiralikbeyin As mentioned in the main project file, www.grc.com doesn't seem to get the right fingerprint. You must use the shell command that is in the file (which uses openssl). I updated my fingerprint right now and it matches correctly. Please do that and check. @pieman64 Google keeps changing the server endpoints (and hence certificates) and it seems they also change based on where in the world you access it from. So there's no way to really have a certificate work for everyone, forever (at least, I don't know how to do that). But please use the technique I mentioned above and extract the certificate fingerprint. It'll should then work correctly, at least for some time, from your location. Sorry, this certificate business is not really my field of expertise. Maybe @igrr could explain it better. I'm busy re-writing the code. I'll upload a newer version soon, making some things easier for developers. Cheers. |
@electronicsguy Thanks, please keep here updated when you are done. I hope you are adding auto-match fp. |
I've been working with Igrr's test code here: https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/examples/HTTPSRequest/HTTPSRequest.ino When I use api.github.com as the host it seems to work. When I use gb.synaptrix.com as the host, it fails - it doesn't even get to the fingerprint verification stage. I have debugging turned on and set to "all" and don't see any kind of messaging for the https handshake. This is the output: wifi evt: 0 How do I troubleshoot this? |
Suggestions from Igrr solved my problem. Hopefully this helps someone else:
|
@DavidTruyens @kiralikbeyin @pieman64 V2.0 uploaded. Core completely re-written. Please check it out. |
Hardware
Hardware: NodeMCU v1.0 ESP-12E
Core Version: 2.1.0
Description
Well.. if someone could offer some enlightenment.. can't find the error in the following (modified host from the original of course..)
It hangs at client.connect for some time.. and then connection fails.
the same happens in "google.com" or "www.google.com"
other hosts work and reply normally
Is it my network?
I've come to believe that it has something to do with dns resolving (or not..)
Of course I've tried setting various DNS and a static IP -commented sections in code- but no result.
Settings in IDE
Module: NodeMCU v1.0
Flash Size: 4MB
CPU Frequency: 80Mhz
Flash Mode: ?qio?
Flash Frequency: ?40Mhz?
Upload Using: SERIAL
Reset Method: ?ck / nodemcu?
Sketch
Debug Messages
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: