-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
HTTPS Server works on raspberrypi but not on espressif #8268
Comments
Hi, thanks for kind word. Unfortunately right now implementing SSL is problematic, due to the amount of compute power necessary, it is very slow and in my testing does not work at all on some microcontrollers. Related issue on CircuitPython itself: Attempt to make a HTTPS server: If you want to play with it, I would appreciate you sharing your results. But if you really need a HTTPS, one way is to use e.g. nginx on Raspberry Pi (Zero/4), but at this point you can simply host a website on it too. |
I've tried using the example on CircuitPython 8.2.0, using both version 4.2.0 and 2.3.0, on an Adafruit Feather ESP32-S2. The error I get is the same on both HTTP server versions. The error below is from my attempt to use version 2.3.0, modified to print the socket type on server start. Here is the error I'm getting.
Here is the line the error is happening at. conn, client_address = self._sock.accept() Hope this helps! |
What are you using for a client? |
During my testing I was getting the exact same error. I was testing using I believe it is something in the CP itself. The interesting thing is that |
I'm using |
The |
I haven't looked much into it, but I think it only has to do with CP. Both |
I loaded up a Pico W and a QT Py S2 and a QT Py S3 (all on CP 8.2.0, all freshly reset). It works on Pico W:
It breaks early in the TLS handshake on S2 and S3:
Same behavior with CP 8.2.2 on S2. Probably some difference in common-hal, or esp-idf. Perhaps we should move this issue to the |
compared to raspberrypi :
|
So we just need to modify the |
There's presumably some |
We could backport this to 8.2.x if it gets figured out soon. |
Is there any progress on fixing/updating ESPs to allow HTTPS? I would like to make an update to |
Why don't we just add ret = mbedtls_ssl_config_defaults(&o->conf,
server_side ? MBEDTLS_SSL_IS_SERVER : MBEDTLS_SSL_IS_CLIENT,
MBEDTLS_SSL_TRANSPORT_STREAM,
MBEDTLS_SSL_PRESET_DEFAULT);
if (ret != 0) {
goto cleanup;
} to |
@michalpokusa or @anecdata did you try @zap8600's suggestion? |
I don't think calling mbedtls APIs here will work, the espressif SSLContext is using ep-idf calls like It's tempted to think we could/should use mbedtls API calls (not esp-idf calls) for both espressif & raspberrypi rp2 (I think this is what micropython does!) but that would be a big change. |
Does anyone have working test code for HTTPS Server for i.e., how do we know this is completed? |
I also started trying HTTPS with |
client side (essentially same output for ESP32-S3 and Pico W:
|
@anecdata please re-test with #8932, which fixes the "Invalid Socket for TLS" message. I tested on esp32-s3 (matrixportal s3) with ide/circuitpython-https-server#2 (however if it's not working on pico w either there's something else going on as well. That port did already set the socket type on an accepted socket, as far as I could tell from reading the source code) |
@jepler works for me now on |
@jepler I also tested on my MatrixPortal S3, works very fast, I also tested with Websockets and But I was unable to make it work with ESP32-S2 Feather TFT, I can start the server but when trying to connect I get an empty @anecdata Could you maybe test on the Feather if you have one on hand? EDIT1: |
I get the same on QT Py ESP32-S2 (N4R2), no dual http/https servers (just https): server:
client:
edit: yes, EESP32-S3 has more internal SRAM than ESP32-S2, but maybe there could be build differences or something else to account for it? I suspect there's some difference of SRAM available to esp-idf. |
If RPicoW with 264kB can handle HTTPS, maybe there is something else here that needs to be fixed? It is definitely better but still not completely working. Would it be worth re-opening this issue? |
I think it needs an issue, either re-open or new. Some difference in S2 vs. S3, and also "https:// PicoW" breaks with latest everything (unless you've gotten it to work?) iirc S2 has 320KB SRAM, and S3 has |
I double checked and you are right, RPicoW now has the same problem as Feather, which is I assumed that considering that only the espressif port changed, code would still work on raspberry. |
Pico W HTTPS Server seems to have broken with the |
CP will try to allocate to PSRAM first now in beta.1+. (Not exactly sure when I changed it.) The IDF can allocate to PSRAM now too by default but needs to request it explicitly. Without an explicit request, then internal memory will be used first. |
Hi,
Thank you for this AWESOME initiative!
Any plan to have an example for SSL http server?
The text was updated successfully, but these errors were encountered: