ESPAsyncWebServer icon indicating copy to clipboard operation
ESPAsyncWebServer copied to clipboard

Can't enable SSL for ESP32: error: 'AcSSlFileHandler' has not been declared

Open strocode opened this issue 3 years ago • 39 comments

Hi,

I'm trying to enable SSL for ESP32 - perhaps this isn't supported? I've scraped together a few hints from various posts.

I'm using platformio and versions described below.

The error I get on compile is:

In file included from src/main.cpp:17:
.pio/libdeps/nodemcu-32s/ESP Async WebServer/src/ESPAsyncWebServer.h:412:27: error: 'AcSSlFileHandler' has not been declared
     void onSslFileRequest(AcSSlFileHandler cb, void* arg);
                           ^~~~~~~~~~~~~~~~
Compiling .pio/build/nodemcu-32s/libea0/WiFi/WiFiUdp.cpp.o
src/main.cpp: In function 'void initSecureWebserver()':
src/main.cpp:85:10: error: invalid user-defined conversion from 'initSecureWebserver()::<lambda(void*, const char*, uint8_t**)>' to 'int' [-fpermissive]
   }, NULL);
          ^
src/main.cpp:69:82: note: candidate is: 'initSecureWebserver()::<lambda(void*, const char*, uint8_t**)>::operator int (*)(void*, const char*, uint8_t**)() const' <near match>
   server.onSslFileRequest([](void * arg, const char *filename, uint8_t **buf) -> int {
                                                                                  ^~~
src/main.cpp:69:82: note:   no known conversion from 'int (*)(void*, const char*, uint8_t**)' {aka 'int (*)(void*, const char*, unsigned char**)'} to 'int'
In file included from src/main.cpp:17:
.pio/libdeps/nodemcu-32s/ESP Async WebServer/src/ESPAsyncWebServer.h:412:10: note:   initializing argument 1 of 'void AsyncWebServer::onSslFileRequest(int, void*)'
     void onSslFileRequest(AcSSlFileHandler cb, void* arg);

Code is:

// Tried to Add SSL but it didn't work
// .pio/libdeps/nodemcu-32s/ESP Async WebServer/src/ESPAsyncWebServer.h:412:27: error: 'AcSSlFileHandler' has not been declared
#define ASYNC_TCP_SSL_ENABLED 1 

#include <Arduino.h>

#define WIFI_SSID "WIFI_SSID_1"
#define WIFI_PASSWORD "PASSWORD_FOR_WIFI_SSID_1"
#include <WiFiMulti.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <ESPmDNS.h>
#include "SPIFFS.h"

WiFiMulti wifiMulti;
AsyncWebServer server(443);


void initWifi()
{
    // Setup wifi
  WiFi.mode(WIFI_STA);
  wifiMulti.addAP(WIFI_SSID, WIFI_PASSWORD);
  while (wifiMulti.run() != WL_CONNECTED) {
    Serial.print(".");
    delay(100);
  }
  Serial.print(' ');
  Serial.println(WiFi.localIP());
}

// Tried to add SSL but it didn't work
// Need to add this; https://github.com/me-no-dev/ESPAsyncWebServer/issues/75
void initSecureWebserver()
{
    // Web Server Root URL
  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send(SPIFFS, "/index.html", "text/html");
  });

  server.serveStatic("/", SPIFFS, "/");

  server.onSslFileRequest([](void * arg, const char *filename, uint8_t **buf) -> int {
    Serial.printf("SSL File: %s\n", filename);
    File file = SPIFFS.open(filename, "r");
    if(file){
      size_t size = file.size();
      uint8_t * nbuf = (uint8_t*)malloc(size);
      if(nbuf){
        size = file.read(nbuf, size);
        file.close();
        *buf = nbuf;
        return size;
      }
      file.close();
    }
    *buf = 0;
    return 0;
  }, NULL);

  // Start server
  server.beginSecure("/Cert.pem", "/Key.pem", NULL);
}

// Initialize SPIFFS
void initSPIFFS() {
  if (!SPIFFS.begin()) {
    Serial.println("An error has occurred while mounting SPIFFS");
  }
  Serial.println("SPIFFS mounted successfully");
}

void setup() {
  Serial.begin(115200);
  initWifi();
  initSPIFFS();
  initSecureWebserver();
}


void loop() {
  Serial.println("Wait 10s");
  delay(10000);
}

platformio.ini is:

[env:nodemcu-32s]
platform = espressif32
board = nodemcu-32s
framework = arduino
monitor_speed = 115200
lib_deps = 
	https://github.com/me-no-dev/ESPAsyncWebServer.git # need latest version as the ESP Async WebServer has bugs

Dependencies are:

> Executing task in folder AsyncServerSSLTEst: platformio pkg list --environment nodemcu-32s <

Resolving nodemcu-32s dependencies...
Platform espressif32 @ 5.0.0 (required: espressif32)
├── framework-arduinoespressif32 @ 3.20003.220626 (required: platformio/framework-arduinoespressif32 @ ~3.20003.0)
├── tool-esptoolpy @ 1.30300.0 (required: platformio/tool-esptoolpy @ ~1.30300.0)
├── tool-mkfatfs @ 2.0.1 (required: platformio/tool-mkfatfs @ ~2.0.0)
├── tool-mklittlefs @ 1.203.210628 (required: platformio/tool-mklittlefs @ ~1.203.0)
├── tool-mkspiffs @ 2.230.0 (required: platformio/tool-mkspiffs @ ~2.230.0)
└── toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3 (required: espressif/toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3)

Libraries
└── ESP Async WebServer @ 1.2.3+sha.f71e3d4 (required: git+https://github.com/me-no-dev/ESPAsyncWebServer.git)
│   └── AsyncTCP @ 1.1.1 (required: me-no-dev/AsyncTCP @ ^1.1.1)

strocode avatar Jul 18 '22 02:07 strocode

[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[bot] avatar Nov 02 '22 00:11 stale[bot]

Did you ever fix this? I have the same issue AcSSlFileHandler has not been declared - that's the only error i get on compile. Everything else works for me.

I have defined #define ASYNC_TCP_SSL_ENABLED 1 at the top level before my includes and generated my key and cert files.

ZanzyTHEbar avatar Nov 08 '22 19:11 ZanzyTHEbar

No, never managed to fix it.

On Wed, 9 Nov 2022 at 06:07, DaOfficialWizard @.***> wrote:

Did you ever fix this? I have the same issue AcSSlFileHandler has not been declared - that's the only error i get on compile. Everything else works for me.

I have defined #define ASYNC_TCP_SSL_ENABLED 1 at the top level before my includes and generated my key and cert files.

— Reply to this email directly, view it on GitHub https://github.com/me-no-dev/ESPAsyncWebServer/issues/1183#issuecomment-1307699718, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOS22PNETMEPJ2BGOYF47LWHKQGJANCNFSM532YLI5A . You are receiving this because you authored the thread.Message ID: @.***>

-- Keith Bannister

strocode avatar Nov 13 '22 05:11 strocode

damn - i wonder why the devs have not added support for the ESP32. Works fine on my ESP8266

ZanzyTHEbar avatar Nov 13 '22 15:11 ZanzyTHEbar

It would be really good to get this supported as we have been using ESPAsyncWebServer for a number of years and the consensus of opinion is that webservers without security are a thing of the past. @me-no-dev any chance this could be done in the near future ?

dmarc1234 avatar Nov 17 '22 13:11 dmarc1234

[STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it openin the future.

stale[bot] avatar Nov 17 '22 13:11 stale[bot]

use https://github.com/yubox-node-org/AsyncTCPSock.git and https://github.com/yubox-node-org/ESPAsyncWebServer remove: { "owner": "me-no-dev", "name": "ESPAsyncTCP", "version": "^1.2.2", "platforms": "espressif8266" }, { "owner": "me-no-dev", "name": "AsyncTCP", "version": "^1.1.1", "platforms": "espressif32" }, in library.json of ESPAsyncWebServer

playmiel avatar Feb 03 '23 11:02 playmiel

Hello, great to see that this is being looked at, thank you.

However I am a little confused, beginSecure() will now compile, as its included within AsyncTCP.h, but there is still no underlying code within AsyncTCP.cpp to start the process ie. there is no beginSecure() routine within AsyncTCP.cpp

What am I missing ?

dmarc1234 avatar Feb 03 '23 15:02 dmarc1234

actually I thought the ssl part was added with AsyncTCPSock but no you can use this example https://github.com/Bmooij/AsyncTCP-https-server-example otherwise or if you can merge this example with the current AsyncTCPSock

playmiel avatar Feb 03 '23 18:02 playmiel

Unfortunately not and the example provided does not include it either.

Digging a little deeper it looks like the ESP8266 version, ESPAsyncTCP, does include beginSecure() but the ESP32 version, AsyncTCP, does not so this functionality has never been implemented in this version of the library.

Not sure what to try next, any ideas ?

dmarc1234 avatar Feb 06 '23 09:02 dmarc1234

Maybe This library - AsyncTCP_SSL

chrisdiphoorn avatar Feb 09 '23 03:02 chrisdiphoorn

this library is for esp32 and includes beginsecure :https://github.com/Bmooij/AsyncTCP.git

playmiel avatar Feb 09 '23 14:02 playmiel

follow the configuration of the example https://github.com/Bmooij/AsyncTCP-https-server-example with

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
build_flags =
    -DCORE_DEBUG_LEVEL=5
    -DASYNC_TCP_SSL_ENABLED
board_build.embed_txtfiles =
    example.crt
    example.key
lib_deps =
    https://github.com/Bmooij/AsyncTCP.git#mbed-tls
    ESP Async [email protected]

in platformio.ini avec les indications que j'ai donner ici

utilisez https://github.com/yubox-node-org/AsyncTCPSock.git et https://github.com/yubox-node-org/ESPAsyncWebServer supprimer : { "owner": "me-no-dev", "name": "ESPAsyncTCP", "version": "^1.2.2", "platforms": "espressif8266" }, { "owner": "me-no-dev", "name": "AsyncTCP", "version": "^1.1.1", "platforms": "espressif32" },dans library.json de ESPAsyncWebServer

playmiel avatar Feb 09 '23 14:02 playmiel

I tested and the code works but it is slow and unstable

playmiel avatar Feb 09 '23 14:02 playmiel

Hello :wave:

You (@playmiel) are saying that yubox-node-org/AsyncTCPSock have an SSL implementation, that part i get it and see it in the code.

I tested and the code works but it is slow and unstable

Are you saying that the ESPAsyncWebServer fork of yubox is working with SSL ?

Because i have read the code for the last 15 mins and i'am pretty sure SSL is not implemented at all.

It will compile fine but its just an empty function so nothing will happen if you start your server with BeginSecure even with yubox-node-org/ESPAsyncWebServer fork.

Because this is the definition of the function beginSecure in yubox-node-org/AsyncTCPSock

#if ASYNC_TCP_SSL_ENABLED
    // Dummy, so it compiles with ESP Async WebServer library enabled.
    void onSslFileRequest(AcSSlFileHandler cb, void* arg) {};
    void beginSecure(const char *cert, const char *private_key_file, const char *password) {};
#endif

So basically Bmooij/AsyncTCP-https-server-example will do nothing since it's executing an empty function.

If i missed something please let me know :+1:

As @dmarc1234 said

It would be really good to get this supported as we have been using ESPAsyncWebServer for a number of years and the consensus of opinion is that webservers without security

In fact, it is mandatory for all Secure IOT Devices.


Have a great day.

justbendev avatar Feb 10 '23 19:02 justbendev

I have had no luck getting ssl working on esp32... Gone back to http for the moment.

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: justbendev @.> Sent: Saturday, February 11, 2023 5:35:08 AM To: me-no-dev/ESPAsyncWebServer @.> Cc: Chris Diphoorn @.>; Comment @.> Subject: Re: [me-no-dev/ESPAsyncWebServer] Can't enable SSL for ESP32: error: 'AcSSlFileHandler' has not been declared (Issue #1183)

Hello 👋

You @.***https://github.com/playmiel) are saying that yubox-node-org/AsyncTCPSockhttps://github.com/yubox-node-org/AsyncTCPSock.git have an SSL implementation, that part i get it and see it in the code.

I tested and the code works but it is slow and unstable

Are you saying that the ESPAsyncWebServer fork of yubox is working with SSL ?

Because i have read the code for the last 15 mins and i'am pretty sure SSL is not implemented at all.

It will compile fine but its just an empty function so nothing will happen if you start your server with BeginSecure even with yubox-node-org/ESPAsyncWebServer fork.

Because this is the definition of the function beginSecure in yubox-node-org/AsyncTCPSock

#if ASYNC_TCP_SSL_ENABLED

// Dummy, so it compiles with ESP Async WebServer library enabled.

void onSslFileRequest(AcSSlFileHandler cb, void* arg) {};

void beginSecure(const char *cert, const char *private_key_file, const char *password) {};

#endif

So basically Bmooij/AsyncTCP-https-server-examplehttps://github.com/Bmooij/AsyncTCP-https-server-example/blob/master/src/main.cpp will do nothing since it's executing an empty function.

If i missed something please let me know 👍

As @dmarc1234https://github.com/dmarc1234 said

It would be really good to get this supported as we have been using ESPAsyncWebServer for a number of years and the consensus of opinion is that webservers without security

In fact, it is mandatory for all Secure IOT Devices.


Have a great day.

— Reply to this email directly, view it on GitHubhttps://github.com/me-no-dev/ESPAsyncWebServer/issues/1183#issuecomment-1426249823, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKWW77SZZGWPBWWTOFU3DITWW2J6ZANCNFSM532YLI5A. You are receiving this because you commented.Message ID: @.***>

chrisdiphoorn avatar Feb 11 '23 01:02 chrisdiphoorn

use this :https://github.com/Bmooij/AsyncTCP.git there is ssl even if it is slow then follow this example :https://github.com/Bmooij/AsyncTCP-https-server-example with what I said above as indication

playmiel avatar Feb 11 '23 11:02 playmiel

Alternative Library

@chrisdiphoorn This is currently the best ESP32 HTTPS Server library HTTPS_Server_Generic it's based on esp32_https_server but without the bugs (Do not use esp32_https_server)


@playmiel Can you please stop sharing BS ? Anyone that have some basics in C++ will immediately understand that Bmooij/AsyncTCP don't handle SSL :exploding_head:

And if you really have the the example code working then you are using an ESP8266 and its out of scope for this issue since we are here talking about ESP32

I'am a bit annonyed because you posted 6 answers, all the same and none of them have any valid information

beginSecure is not even declared in this code... (AsyncTCP)

use this :https://github.com/Bmooij/AsyncTCP.git there is ssl even if it is slow then follow this example :https://github.com/Bmooij/AsyncTCP-https-server-example with what I said above as indication

I highly doubt it , if using an ESP32

I tested and the code works but it is slow and unstable

beginSecure is not even declared in this code... (AsyncTCP)

this library is for esp32 and includes beginsecure :https://github.com/Bmooij/AsyncTCP.git

As explained before the beginSecure here is an empty function just so the code would compile

#if ASYNC_TCP_SSL_ENABLED
    // Dummy, so it compiles with ESP Async WebServer library enabled.
    void onSslFileRequest(AcSSlFileHandler cb, void* arg) {};
    void beginSecure(const char *cert, const char *private_key_file, const char *password) {};
#endif

actually I thought the ssl part was added with AsyncTCPSock but no you can use this example https://github.com/Bmooij/AsyncTCP-https-server-example otherwise or if you can merge this example with the current AsyncTCPSock

Again dummy function explained above

use https://github.com/yubox-node-org/AsyncTCPSock.git and https://github.com/yubox-node-org/ESPAsyncWebServer remove: { "owner": "me-no-dev", "name": "ESPAsyncTCP", "version": "^1.2.2", "platforms": "espressif8266" }, { "owner": "me-no-dev", "name": "AsyncTCP", "version": "^1.1.1", "platforms": "espressif32" }, in library.json of ESPAsyncWebServer

justbendev avatar Feb 11 '23 14:02 justbendev

hello if possible I will make a complete example to show you that it really works , It's true that the explanations are bad, sorry

playmiel avatar Feb 13 '23 23:02 playmiel

ive had a look at the code - looks fine and i will need to change mycode to get this working.... but still need to investigate the missing processor function.... where i currently pass values back into the HTML code as the page is rendered in the DOM.

server.on("/config.html", HTTP_GET, [](AsyncWebServerRequest *request){ request->send(SPIFFS, "/config.html", String(), false, processor); });

String processor(const String& var){

  if (var == "DEVID"){
    return String(DEVflash.id);
  }
  if (var == "DEV") {
    return String(DEVflash.dev_name);
  }
  if (var == "DEV_USER" ){
    return String(DEVflash.dev_username);
  }

... Replaces "$DEVID$" witht the DEVflash.id value.

Is this the same as using this.. (&handleSwitch)? ResourceNode * nodeSwitch = new ResourceNode("/led//", "POST", &handleSwitch);

A little more complicated than what im currently using....

Regards

Chris Diphoorn


From: justbendev @.> Sent: Sunday, 12 February 2023 12:18 AM To: me-no-dev/ESPAsyncWebServer @.> Cc: Chris Diphoorn @.>; Mention @.> Subject: Re: [me-no-dev/ESPAsyncWebServer] Can't enable SSL for ESP32: error: 'AcSSlFileHandler' has not been declared (Issue #1183)

Alternative Library

@chrisdiphoornhttps://github.com/chrisdiphoorn This is currently the best ESP32 HTTPS Server library HTTPS_Server_Generichttps://github.com/khoih-prog/HTTPS_Server_Generic it's based on esp32_https_serverhttps://github.com/fhessel/esp32_https_server but without the bugs (Do not use esp32_https_server)

— Reply to this email directly, view it on GitHubhttps://github.com/me-no-dev/ESPAsyncWebServer/issues/1183#issuecomment-1426780734, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKWW77UBL3LT45VEOZASTLLWW6NUHANCNFSM532YLI5A. You are receiving this because you were mentioned.Message ID: @.***>

chrisdiphoorn avatar Feb 14 '23 11:02 chrisdiphoorn

So I think I am getting a little closer, the branch https://github.com/Bmooij/AsyncTCP/tree/mbed-tls does include the function beginSecure() within AsyncTCP.cpp and there are two other files tcp_mbedtls.c and tcp_mbedtls.h that are included for TLS support. The only problem is that when trying to compile you get two errors as follows:

tcp_mbedtls.cpp:760: undefined reference to _tcp_write4ssl(tcp_pcb*, char const*, unsigned int, unsigned char, void*) tcp_mbedtls.cpp:760: undefined reference to _tcp_output4ssl(tcp_pcb*, void*)

I think these are due to the jump pad definitions in AsyncTCP.cpp as follows:

// Jump pads for _tcp_*4ssl function below to get access to _closed_slot.
// I'm sure there has to be a better way to do this...

esp_err_t AsyncClient::_tcp_output4ssl(tcp_pcb * pcb) {
    return _tcp_output(pcb, _closed_slot);
}

esp_err_t AsyncClient::_tcp_write4ssl(tcp_pcb * pcb, const char* data, size_t size, uint8_t apiflags) {
    return _tcp_write(pcb, _closed_slot, data, size, apiflags);
}

Does anyone have any ideas ?

dmarc1234 avatar Feb 21 '23 14:02 dmarc1234

use https://github.com/yubox-node-org/AsyncTCPSock.git and https://github.com/yubox-node-org/ESPAsyncWebServer remove: { "owner": "me-no-dev", "name": "ESPAsyncTCP", "version": "^1.2.2", "platforms": "espressif8266" }, { "owner": "me-no-dev", "name": "AsyncTCP", "version": "^1.1.1", "platforms": "espressif32" }, in library.json of ESPAsyncWebServer

In fact there is a conflict with the dependencies of asyncwebserver as I say it is necessary to remove it from the library.json file of asyncwebserver otherwise it changes the version of asynctcp that you have by asynctcp 1.1

playmiel avatar Feb 21 '23 16:02 playmiel

after that delete the two asynctcp then reinstall the version of Bmooij

playmiel avatar Feb 21 '23 16:02 playmiel

That library, as discussed above does not work, it does not have beginSecure() declared and therefore does nothing.

dmarc1234 avatar Feb 21 '23 17:02 dmarc1234

oh sorry I misspoke, I meant to remove { "owner": "me-no-dev", "name": "ESPAsyncTCP", "version": "^1.2. 2", "platforms": "espressif8266" }, { "owner": "me-no-dev", "name": "AsyncTCP", "version": "^1.1.1", "platforms": "espressif32" }, in library.json of ESPAsyncWebServer (from me-no-dev) and after that delete the two asynctcp then reinstall the version of Bmooij

playmiel avatar Feb 21 '23 18:02 playmiel

Getting closer, can now get https://github.com/Bmooij/AsyncTCP/tree/mbed-tls to compile when added the standard ESPAsyncWebServer and have the HTTPs server starting:

T network_event- Loading the server cert
T network_event- Loading the server key
T network_event- Seeding the random number generator...
T network_event- Setting up the SSL data...
T network_event- tcp_ssl_new_server completed succesfully

and delivering simple XML and HTML:

T async_tcp- tcp_ssl_read(3ffe2b70, 3fff9b30)
T async_tcp- start handshake: 0
T async_tcp- tcp_ssl_recv: ctx: 0x3FFF0760, buf: 0x3FFF0E98, len: 5
T async_tcp- tcp_ssl_recv: len: 5, recv_len: 5, pbuf_offset: 0, tcp_pbuf len: 517.
T async_tcp- tcp_ssl_recv: ctx: 0x3FFF0760, buf: 0x3FFF0E9D, len: 512
T async_tcp- tcp_ssl_recv: len: 512, recv_len: 512, pbuf_offset: 5, tcp_pbuf len: 517.
T async_tcp- tcp_ssl_send: ctx: 0x3FFF0760, buf: 0x3FFF4FF8, len: 96
T async_tcp- tcp_ssl_send: tcp_write(3ffe2b70, 3fff4ff8, 96, 3fff0644)
T async_tcp- tcp_ssl_send: tcp_output: 96 / 96
T async_tcp- tcp_ssl_send: ctx: 0x3FFF0760, buf: 0x3FFF4FF8, len: 1025
T async_tcp- tcp_ssl_send: tcp_write(3ffe2b70, 3fff4ff8, 1025, 3fff0644)
T async_tcp- tcp_ssl_send: tcp_output: 1025 / 1025
T async_tcp- tcp_ssl_send: ctx: 0x3FFF0760, buf: 0x3FFF4FF8, len: 406
T async_tcp- tcp_ssl_send: tcp_write(3ffe2b70, 3fff4ff8, 406, 3fff0644)
T async_tcp- tcp_ssl_send: tcp_output: 406 / 406
T async_tcp- tcp_ssl_send: ctx: 0x3FFF0760, buf: 0x3FFF4FF8, len: 9
T async_tcp- tcp_ssl_send: tcp_write(3ffe2b70, 3fff4ff8, 9, 3fff0644)
T async_tcp- tcp_ssl_send: tcp_output: 9 / 9
T async_tcp- tcp_ssl_recv: ctx: 0x3FFF0760, buf: 0x3FFF0E98, len: 5
T async_tcp- tcp_ssl_recv: len: 5, recv_len: 0, pbuf_offset: 517, tcp_pbuf len: 517.
T async_tcp- tcp_ssl_read: return total_bytes: 0
T async_tcp- tcp_ssl_read(3ffe2b70, 3fffaf44)
T async_tcp- start handshake: 8
T async_tcp- tcp_ssl_recv: ctx: 0x3FFF0760, buf: 0x3FFF0E98, len: 5
T async_tcp- tcp_ssl_recv: len: 5, recv_len: 5, pbuf_offset: 0, tcp_pbuf len: 194.
T async_tcp- tcp_ssl_recv: ctx: 0x3FFF0760, buf: 0x3FFF0E9D, len: 138
T async_tcp- tcp_ssl_recv: len: 138, recv_len: 138, pbuf_offset: 5, tcp_pbuf len: 194.
T async_tcp- tcp_ssl_recv: ctx: 0x3FFF0760, buf: 0x3FFF0E98, len: 5
T async_tcp- tcp_ssl_recv: len: 5, recv_len: 5, pbuf_offset: 143, tcp_pbuf len: 194.
T async_tcp- tcp_ssl_recv: ctx: 0x3FFF0760, buf: 0x3FFF0E9D, len: 1
T async_tcp- tcp_ssl_recv: len: 1, recv_len: 1, pbuf_offset: 148, tcp_pbuf len: 194.
T async_tcp- tcp_ssl_recv: ctx: 0x3FFF0760, buf: 0x3FFF0E98, len: 5
T async_tcp- tcp_ssl_recv: len: 5, recv_len: 5, pbuf_offset: 149, tcp_pbuf len: 194.
T async_tcp- tcp_ssl_recv: ctx: 0x3FFF0760, buf: 0x3FFF0E9D, len: 40
T async_tcp- tcp_ssl_recv: len: 40, recv_len: 40, pbuf_offset: 154, tcp_pbuf len: 194.
T async_tcp- tcp_ssl_send: ctx: 0x3FFF0760, buf: 0x3FFF4FF8, len: 6
T async_tcp- tcp_ssl_send: tcp_write(3ffe2b70, 3fff4ff8, 6, 3fff0644)
T async_tcp- tcp_ssl_send: tcp_output: 6 / 6
T async_tcp- tcp_ssl_send: ctx: 0x3FFF0760, buf: 0x3FFF4FF8, len: 45
T async_tcp- tcp_ssl_send: tcp_write(3ffe2b70, 3fff4ff8, 45, 3fff0644)
T async_tcp- tcp_ssl_send: tcp_output: 45 / 45
T async_tcp- Protocol is TLSv1.2 Ciphersuite is TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384
T async_tcp- Verifying peer X.509 certificate...T async_tcp- handshake error: 0
T async_tcp- 
T async_tcp- MbedTLS message code: 0
T async_tcp- tcp_ssl_read: return total_bytes: 0
T async_tcp- tcp_ssl_read(3ffe2b70, 3fff92c0)
T async_tcp- tcp_ssl_recv: ctx: 0x3FFF0760, buf: 0x3FFF0E98, len: 5
T async_tcp- tcp_ssl_recv: len: 5, recv_len: 5, pbuf_offset: 0, tcp_pbuf len: 750.
T async_tcp- tcp_ssl_recv: ctx: 0x3FFF0760, buf: 0x3FFF0E9D, len: 745
T async_tcp- tcp_ssl_recv: len: 745, recv_len: 745, pbuf_offset: 5, tcp_pbuf len: 750.
T async_tcp- tcp_ssl_read: read_bytes: 721, total_bytes: 0, tot_len: 750, pbuf_offset: 750
T async_tcp- tcp_ssl_write(3ffe2b70, 3fffa704, len=1492)
T async_tcp- tcp_ssl_send: ctx: 0x3FFF0760, buf: 0x3FFF4FF8, len: 1521
T async_tcp- tcp_ssl_send: tcp_write(3ffe2b70, 3fff4ff8, 1521, 3fff0644)
T async_tcp- tcp_ssl_send: tcp_output: 1521 / 1521
T async_tcp- tcp_ssl_recv: ctx: 0x3FFF0760, buf: 0x3FFF0E98, len: 5
T async_tcp- tcp_ssl_recv: len: 5, recv_len: 0, pbuf_offset: 750, tcp_pbuf len: 750.
T async_tcp- tcp_ssl_read: read_bytes: -26880, total_bytes: 721, tot_len: 750, pbuf_offset: 750
T async_tcp- tcp_ssl_read: return total_bytes: 0
T async_tcp- tcp_ssl_write(3ffe2b70, 3fffa704, len=8)
T async_tcp- tcp_ssl_send: ctx: 0x3FFF0760, buf: 0x3FFF4FF8, len: 37
T async_tcp- tcp_ssl_send: tcp_write(3ffe2b70, 3fff4ff8, 37, 3fff0644)
T async_tcp- tcp_ssl_send: tcp_output: 37 / 37
T async_tcp- tcp_ssl_read(3ffe2b70, 3fffa52c)
T async_tcp- tcp_ssl_recv: ctx: 0x3FFF0760, buf: 0x3FFF0E98, len: 5
T async_tcp- tcp_ssl_recv: len: 5, recv_len: 5, pbuf_offset: 0, tcp_pbuf len: 31.
T async_tcp- tcp_ssl_recv: ctx: 0x3FFF0760, buf: 0x3FFF0E9D, len: 26
T async_tcp- tcp_ssl_recv: len: 26, recv_len: 26, pbuf_offset: 5, tcp_pbuf len: 31.
T async_tcp- tcp_ssl_read: read_bytes: -30848, total_bytes: 0, tot_len: 31, pbuf_offset: 31
T async_tcp- tcp_ssl_read: return total_bytes: -30848
T async_tcp- tcp_ssl_free(3ffe2b70)

But when you try to access a page that is > a few kilobytes things start to fall apart:

T async_tcp- tcp_ssl_write(3ffe2b54, 3fff9bb8, len=4253)
T tiT- failed: mbedtls_ssl_setup returned -0x7f00
:T-a2512cbed4LACmeleage4cod locat0o3Ffai160
         tcp- tcp_ssl_send: tcp_write(3ffe2b54, 3fff47ac, 2872, 3fffd044)
E (79943) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (79943) task_wdt:  - async_tcp (CPU 0/1)
E (79943) task_wdt: Tasks currently running:
E (79943) task_wdt: CPU 0: IDLE0
E (79943) task_wdt: CPU 1: IDLE1
E (79943) task_wdt: Aborting.
abort() was called at PC 0x400facbc on core 0

Backtrace: 0x4008e3f8:0x3ffbe170 0x4008e629:0x3ffbe190 0x400facbc:0x3ffbe1b0 0x40085815:0x3ffbe1d0 0x401b37a7:0x3ffbc120 0x400fc7f6:0x3ffbc140 0x4008c2a5:0x3ffbc160 0x4008aab1:0x3ffbc180

Backtrace is a little non-descript:

Decoding stack results
0x4008e3f8: invoke_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 155
0x4008e629: abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 170
0x400facbc: task_wdt_isr at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/task_wdt.c line 174
0x401b37a7: esp_pm_impl_waiti at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/pm_esp32.c line 492
0x400fc7f6: esp_vApplicationIdleHook at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/freertos_hooks.c line 63
0x4008c2a5: prvIdleTask at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c line 3382
0x4008aab1: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143

But looks like a memory corruption issue within SSL that's causing the WDT timeout.

Possible buffer issue so has anyone any idea where the allocations are done.

Very nearly there and page delivery speed is not too bad so definitely usable.

dmarc1234 avatar Mar 21 '23 15:03 dmarc1234

I tested things to try to correct these problems but it does not give anything, even increasing the memory for the processing of the asyntcp task it does not work, in my opinion it should completely review the processing mbedtls

playmiel avatar Apr 11 '23 09:04 playmiel

[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[bot] avatar Jun 18 '23 13:06 stale[bot]

I tested things to try to correct these problems but it does not give anything, even increasing the memory for the processing of the asyntcp task it does not work, in my opinion it should completely review the processing mbedtls

Any other directions or suggestions?

kbhuinfo avatar Jun 20 '23 08:06 kbhuinfo

[STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it openin the future.

stale[bot] avatar Jun 20 '23 08:06 stale[bot]