-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Feature Request: ESP32 SSL/TLS Certificate Store #3646
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
Porting BearSSL would be a very significant task, particularly to use the hardware acceleration. However, if you attempt to create an https connection in WiFiClientSecure with no CA/cert information, it will make permissive requests, and should accept any certificate offered. Perhaps posting your actual issue (with code and logs) instead of your proposed fix can resolve the root problem. |
That really isn't a solution though is it? That's just leaving a key under the doormat because you keep losing your keys - you may as well just leave the door open. What I want to be able to do is connect to any arbitrary https web service from within a sketch without having to load an individual root CA for each domain and keep track of which is which. I can do that on the ESP8266 using Essentially I would like to recreate this ESP8266 sketch on the ESP32 and have it function with the same level of security. When I replace
|
Ok, so you want a certificate store, not BearSSL. I'd suggest you change the title if you want anybody to look at it- a cert store is significantly easier than an encryption library. The feature set of esp32 is completely different than esp8266, so won't be an exact analogue, but it should be possible to do it with less resources. |
Thank you for your guidance, I have changed the title as you suggested.
It would make sense for it to be implemented with the same "API" as the |
@lbernstone I just observed this behaviour. Could you please shed some light into why this is allowed and why this happens? If no certificate/a corrupted certificate is provided, shouldn't the library throw an error? It currently says "Certificate verified" which is incorrect. I am not an expert on SSL, just wanting to understand the implications of this behaviour and the need of even providing a cert in light of this (and associated security concerns). I personally noticed this while trying to corrupt my ca cert and noticing what happens. |
[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. |
Would be better if this could be flagged as a feature request rather than a stale issue. |
[STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it openin the future. |
Did you already take a look at https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/protocols/esp_crt_bundle.html? |
@kinafu - that's a promising start. Unfortunately only available in the ESP-IDF though. If that functionality (particularly the ability to store the cert bundle in SPIFFS/LittleFS) were to be ported here to Arduino-ESP32 then that would, I think, close this feature request. |
With a few modifications to the I had to manually create the |
PlatformIO offers similar functionality for embedding files in the binary: http://docs.platformio.org/en/latest/platforms/espressif32.html#embedding-binary-data |
Yeah, that's what I used to embed the binary that the script created.
…On Tue, Jun 23, 2020, 7:36 AM Mike Dunston ***@***.***> wrote:
I had to manually create the x509_crt_bundle binary with the the
esp_crt_bundle/gen_crt_bundle.py script and embedded into my sketch. I
use platformio, so I'm going to make an extra_script to automate that
process. In IDF, the CMakeLists.txt file does this for you.
PlatformIO offers similar functionality for embedding files in the binary:
http://docs.platformio.org/en/latest/platforms/espressif32.html#embedding-binary-data
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3646 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABPBQCCWAH7V5H5OUBG6DGDRYCOWHANCNFSM4KIZ2FZA>
.
|
That sounds promising! Would you mind sharing your modified
|
I added the modified |
TL;DR - None of this is necessary...
EDIT: undef added to build_flags |
It seems like changing the
It assumes the certificates are in a |
It's my understanding that the |
[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. |
[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions. |
I modified the arduino-esp32 according to the discussed / proposed changes (thx @meltdown03). To test the modifications I created an example sketch (as platformio project). I looked into the problem for some hours now and did not get it to work unfortunately. You can try my changes quickly by checking out my test repository in your editor with platformio installed. The example sketch should be fine. The failure probably lies in my arduino-esp32 modifications. |
hey |
This comment has been minimized.
This comment has been minimized.
@meltdown03 please do! I'm interested to see what you come up with. I've failed miserably in solving this ;) Keep in mind that we would like to make a PR that should work for Arduino users out of the box and not everyone will use the bundle. For our personal cases this already workes. So thanks for your original post pointing us in this direction! |
poking the issue a bit so stale bot doesn't get angry. |
Just an fyi, and it isn't there yet in arduino, but esp-idf now includes a certificate bundle as cert binaries. It is not a comprehensive set, but will get you into many cloud services, and will be 64kb of code space. |
@lbernstone not sure but I believe we are already using what you are referring to:
If this was not what you meant or we are on the wrong track please let me know!? Otherwise, I'll try and make a PR this weekend as @Duckle29 seems too busy and does not have the time... |
I mean it will be included in the compiled libraries once the weird naming from esp-idf is resolved. You will not need any external library, just an include. |
@lbernstone thank you for clarifying! Would you still be interested in my PR regarding client.loadCertBundle() which lets you basically load the same bundle but then from a FS? |
Anything goes on external libraries. If you make an example using one of those root CAs, then it should be usable as an example here too. |
@lbernstone thank you, Ill make a PR this weekend. |
Bumping the issue :) |
Also interested in this feature, @yknivag has a nice approach for doing OTA based on GitHub releases that relies on this and I think it would be a really worthy addition to the esp32 |
Pinging it again so Stalebot doesn’t make a move first. |
Is there any news on this? |
Just that it still isn't implemented |
I was also trying to solve this issue, and this ticket was very helpful. Edit: Here is the modified example to use the certificates directly from flash: https://github.com/esp32wrangler/esp32-certBundle But modifying on top of all the existing modifications is unnecessarily messy. It is enough to
|
Enable usage of the ESP32 IDF's certificate bundle for WiFiClientSecure connections. Adds the ability to load a bundle or root certificates and use them for authenticating SSL servers. Based on work from Onno-Dirkzwager, Duckle29, kubo6472, meltdown03, kinafu and others. See also: - https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/protocols/esp_crt_bundle.html - espressif#3646 - libraries/WiFiClientSecure/README.md
I cleaned up the changes and made a change set that may be acceptable upstream. I have zero experience with this project, so I would appreciate if someone could check if the changes follow the project norms. |
* Add certificate bundle capability to WiFiClientSecure Enable usage of the ESP32 IDF's certificate bundle for WiFiClientSecure connections. Adds the ability to load a bundle or root certificates and use them for authenticating SSL servers. Based on work from Onno-Dirkzwager, Duckle29, kubo6472, meltdown03, kinafu and others. See also: - https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/protocols/esp_crt_bundle.html - #3646 - libraries/WiFiClientSecure/README.md * Fix build issues * Clean up old bundle index when NULL bundle is attached
Enable usage of the ESP32 IDF's certificate bundle for WiFiClientSecure connections. Adds the ability to load a bundle or root certificates and use them for authenticating SSL servers. Based on work from Onno-Dirkzwager, Duckle29, kubo6472, meltdown03, kinafu and others. See also: - https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/protocols/esp_crt_bundle.html - espressif#3646 - libraries/WiFiClientSecure/README.md [Copied verbatim from upstream]
Enable usage of the ESP32 IDF's certificate bundle for WiFiClientSecure connections. Adds the ability to load a bundle or root certificates and use them for authenticating SSL servers. Based on work from Onno-Dirkzwager, Duckle29, kubo6472, meltdown03, kinafu and others. See also: - https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/protocols/esp_crt_bundle.html - espressif#3646 - libraries/WiFiClientSecure/README.md [Copied verbatim from upstream]
I am also interested in this capability. I am developing an IoT project in the Arduino IDE which communicates with Google App Script and am unfortunately getting this error whenever I perform a GET request: [E][ssl_client.cpp:36] _handle_error(): [data_to_read():287]: (-29184) SSL - An invalid SSL record was received I am using the HTTPSRedirect library, which just wraps the WiFiClientSecure GET method without any modification. An initial client.connect() works provided that .setInsecure() is used first, however a subsequent GET request just hangs the ESP32 although I still get the above message in the Serial Monitor when 'debug' log level is selected. Whether that's down to Google increasing security, changing their cert or the library not working as it should be, I don't know although I am assuming at this point that the problem is that the GET request can't be performed without having a valid certificate chain in place? I have tested ESP32 Library versions 1.0.5 and 1.0.6 with the same result. |
Hello, Due to the overwhelming volume of issues currently being addressed, we have decided to close the previously received tickets. If you still require assistance or if the issue persists, please don't hesitate to reopen the ticket. Thanks. |
Is it possible to handle https connections on the ESP32 without knowing in advance the root CA for the service one is trying to connect to?
For example, on the ESP8266 this is possible using
CertStoreBearSSL
(see https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WiFi).This is particularly important for https services which redirect from one domain to another where one would need to know all the certificates in advance on the ESP32 whereas on the ESP8266 one needs only to add
certs.ar
to SPIFFS and it is possible to connect to almost any https service.I may have missed a way that this is already possible but I haven't been able to find one. How complex would it be to port the
CertStoreBearSSL
functionality to the ESP32?The text was updated successfully, but these errors were encountered: