-
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
SSL support #43
Comments
SSL has been ~broken since 0.9.3-patch1 (and you needed a new libssl, separate from patch1, from Espressif.) It's supposedly fixed again in 1.0.1b2 (you still need a special libssl for the moment) - http://bbs.espressif.com/viewtopic.php?f=5&t=382 - I haven't had a chance to try it yet, but I've heard good reports. There are still some features missing for practical SSL - iirc there's no way to pin a certificate or do trust validation, it'll silently accept self-signed certs - but it's still a huge positive step. |
i have add the latest sdk + ssl patches |
Merged that, thanks. |
@igrr does this issue cover adding HTTPS support to a WebClient application for accessing secure-connection-only APIs? What's the roadmap/timeline for including this feature? Is it actually possible? |
@Links2004 @igrr Do I read this thread correctly that there is support for an HTTPS WebClient built into the core now, but WiFiClient class "just" needs that core functionality integrated into it? |
Yes - HTTPS is just HTTP over SSL sockets, so once SSL sockets are integrated with WiFiClient/WiFiServer, you should be able to talk to HTTPS servers.
I'm not very familiar with this project's codebase.
Yes. Other projects (like https://github.com/tuanpmt/esp_bridge) are able to make HTTPS requests from an ESP8266. The primary limiting factor is certificate size and protocol support (TLS v1.2 is not yet supported and is mandatory for some servers) - and that the Espressif SDK doesn't always have working SSL built in to it (it works now!)
It's now possible to write a WiFiClient that opens a secure socket. The existing WebClient shouldn't need major changes. |
@abl cool, I need to come up to speed on on getting a dev environment set up so I can contribute... |
looking forward to SSL support as well for ESP8266. I am looking at using Golgi.io arduino stack as an option for the SSL shim as they provide other time saving and mission critical networking support functions. |
@igrr @Links2004 can you give any pointers on how to use axTLS to implement HTTPS capability into WiFiClient/WiFiServer? Any updates on progress here would be appreciated. I personally would like to see the WiFiClient capability implemented as the priority. Would it be beneficial splitting this issue into two; one for WiFiClient and one for WiFiServer? |
@vicatcu |
@igrr ah yes of course, that (that WiFiClient is not just about HTTP) makes a lot of sense. |
@vicatcu , have you started to implement the TLS on the WiFiClient? I need to connect to a webserver using https, and I'm interested in this functionality, and could try to help (don't know if I am able to do it, no previous experience with HTTPS or TLS). Best regards Fernando |
@fmgomes honestly I haven't really gotten anywhere yet - it's a pretty steep learning curve for me so I'm kind of in the same boat as you :-/. It's a bit frustrating to know it's possible for the last few months, but that I haven't had time / know-how / etc to help make it happen. @igrr spelled out what needs to happen pretty well in his last response, but I'm not sure what "certificate management" requires... |
When a client connects to a server and performs a TLS handshake (which is what turns a socket in to a secure socket, and HTTPS is just HTTP on a secure socket) the server sends over a certificate. The certificate is what identifies the server; without the certificate validation step, HTTPS prevents against eavesdropping but you could potentially be communicating with an attacker (aka a MitM attack.) Validating a certificate:
1 should be pretty easy to implement; the names should be exactly equal. Wildcard certificates exist but are considered harmful; not supporting them is probably fine for v1. 2 can probably be ignored for now; the vast majority of ESP8266 work will be bound to specific certificates because... 3 is the most complex part. On a normal computer, the OS (and sometimes the browser) maintains a list of trusted root certificates. For Debian, the size of this certificate package is 502kB (see https://packages.debian.org/sid/ca-certificates) - it's possible to shrink this down a bit but it's obviously a nonstarter for the average ESP8266 project. An alternative to this is simply maintaining a list of certificate fingerprints and checking that instead - creating an explicit whitelist of certificates. That's what I'd recommend - and when you're using certificate fingerprints, you can be lax about expiration and revocation and manage it yourself. 4 is a complicated topic - check out CRL and OCSP if you're curious - and way beyond what we'd want to do in an embedded system. AxTLS probably has simple-ish calls to handle all of this; they'd need to be exposed via SecureWifiClient. SecureWifiServer would need a new method that allows a user to set the public and private key to use. |
does thread this also cover applying TLS to MQTT eventually? |
For what I've read, adding https support is a little bit hard. But what about simple ciphering, for direct socket communication? Something with a symmetric key, that would be a good start. I've read in the Espressif page that ESP8266 has a built in AES engine, but they don't specify if it is hardware or software based. Has anyone tried it? |
Just a comment on that list of work from @abl - to get going i'd be quite happy to not have any of that certificate validation stuff. Wont be sending my bank account details or anything top secret just need to post to a remote service that only supports https. So just binning the certificate after its read would be fine for my uses. |
If you just want to prevent un-authorized use rather then hid the messages, check out this page on using SipHash as a secure hash. |
So what's the latest?
|
Is it now possible to make a HTTPS request? |
Started working on TLS support: https://github.com/igrr/axtls-8266 |
Going that route, it seems like wolfSSL and mbed TLS (well, especially mbed TLS) might be easier to bring in, although we know axTLS works since Espressif has it working :) They also support TLS 1.2. |
Both wolfSSL and PolarSSL (aka mbed TLS) are GPL (not LGPL) unless you On Wed, Sep 2, 2015, 21:24 Alexander [email protected] wrote:
|
@igrr one of your future milestones was "release memory allocated for certificate storage after check is complete" has that been implemented yet? I'm now running into a memory issue:
I try to malloc them memory I need after the handshake, but at that point ESP.getFreeHeap() only shows 12KB available. Before the client.conneect call it is 27KB+. I |
It is implemented in 2.1.0. After WiFiClient::connect returns, certificate will be kept until the first call to |
@igrr - You're frikin awesome. I've just spent 15 minutes reading this. I haven't even tried to use it yet but I'm already grateful for all your work... |
Yes, @igrr is super awesome and needs to show us a paypal donate button so we can show our appreciation. I've added some of my own debug as well as turned on the builtin. Here's what I got:
So with 38KB free originally, 30KB are consumed during the handshake and 4KB are given back right away, leaving the user with 12KB free. After the first write call, an additional 7KB are given back, bringing free mem to 19KB with the connection open. @igrr Is this the expected behavior? Are there any other improvements you could suggest on the server end to optimize memory usage? My application is a IoT sensor that will include a 1 or 2 second WAV file recorded by the ESP8266, That's why I'm being a stickler for memory. |
is there a known issue with Let's Encrypt certificates? because I get please start sntp first ! |
@krebbi does the server allow TLS 1.1? axTLS doesn't support TLS 1.2, which may be the reason for this error. |
TLS 1.0, 1.1 and 1.2 |
or is RSA 4096 bits too big? |
I believe this ESP version only supports AES 128 or 256 |
these Cipher Suites are supported by my cert: TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (0xc030) ECDH secp256r1 (eq. 3072 bits RSA) FS 256 |
@igrr Do you know if NGINX supports max_fragment_length negotiation ? |
@igrr Could someone please tell me if https can work on the ESP-01? |
@electronicsguy some https connections will work, some won't. It has to do with the TLS version, the used ciphers, and/or the configuration of the webserver. |
It turns out that you can set SSL fragment size in NGINX (>= 1.5.9 ). The directive is called ssl_buffer_size. And there is no need to recompile NGINX. |
@svdgraaf @igrr Thanks for the follow-up. I am still trying to understand the details. All I want to do is send data from esp8266 directly into a google spreadsheet (without using a http to https converter service like pushingbox). So is incorporating support for TLS1.2 unachieveable with the current esp hardware? Or is it a matter of someone writing up that code, which has just not been done as yet? |
Anyone got TLS1.2 working yet and a way to add trusted certs ? |
@AdamMiltonBarker! |
wolfSSL has already been discussed, and the problem is it is GPL and not LGPL. I am not sure I understand the difference, to be honest. |
For my project it would´nt be important whether GPL or LGPL. |
I agree I think security is more important that the license. |
@igrr - I too greatly appreciate all you do for the esp8266 community. Having been developing on this hardware for the last year I could not have done it without you! I am having trouble with the WiFiClientSecure implementation though. I basically have the exact same code for HTTP as HTTPS but I never get the response back from the server with SSL (unless I remove From my debug output, I see the
|
@DaKaZ I get body of response using @igrr's example |
Very interesting... thanks @chaeplin - So I changed the multiple |
If anyone comes across this thread - here is a working version of the RestClient with SSL support: https://github.com/DaKaZ/esp8266-restclient Enjoy |
If there's an issue storing certificates in RAM, is it possible you could stream them into the file system and walk through them there? (Note: I've also seen a hack to upgrade the flash to 4M or bigger, so you might be able to store a fair bit) |
What the plans for secure server? I feel this is a major let down, if we can provide secure endpoints to customers on the ESP I think it would be a massive improvement. |
Hi!
I would like to know if you plan to include SSL support in the libraries.
I've tryed to send some https requests with no sucess.
It would be cool if it the ESP could act as a secure server too.
I've checked the some examples from the sdk and they have a code to create a secure server with digital certificate.
Thanks!
The text was updated successfully, but these errors were encountered: