RAM usage for mbedtls

snahmad75
Posts: 131
Joined: Wed Jan 24, 2018 6:32 pm

Re: RAM usage for mbedtls

Postby snahmad75 » Thu May 17, 2018 4:20 pm

I added more logs. Any idea why socket class fail to receive.

s_ssl_read_record_layer() returned -29312 (-0x7280)
D (18046) Socket: rc=0, MBEDTLS_ERR_SSL_WANT_READ=-26880
D (18052) Socket: << accept: sockFd: 4100
D (18058) HttpServerTask: HttpServer that was listening on port 443 has receiv
ed a new client connection; sockFd=4100
Stack free: 6688
Internal Heap free: 76208
Heap free: 10616:76208
D (18073) HttpParser: >> parse: socket: fd: 4100
D (18077) Socket: Socket::readToDelim=

User avatar
kolban
Posts: 1436
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: RAM usage for mbedtls

Postby kolban » Thu May 17, 2018 4:35 pm

According to the mbedtls docs, error code -0x7280 means that the connection indicated an End Of File condition:

https://tls.mbed.org/api/ssl_8h.html#ab ... 8ef9eb97f9

As to the cause, no idea. If it were me, I'd start looking at the client traces to see if we can see any rejection messages that might guide us. Worst case, we'd have to drop down to WireShark and examine the SSL protcol handshakes to see if we can spot why the connection is being closed.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

snahmad75
Posts: 131
Joined: Wed Jan 24, 2018 6:32 pm

Re: RAM usage for mbedtls

Postby snahmad75 » Thu May 17, 2018 4:50 pm

I tried both client. My c++ application running on PC and chrome web browser.
Let me check if i get same error using these two client. i will check wire-shark logs tomorrow.

This is Https session can i see encrypted messages.

snahmad75
Posts: 131
Joined: Wed Jan 24, 2018 6:32 pm

Re: RAM usage for mbedtls

Postby snahmad75 » Thu May 17, 2018 8:40 pm

To let you know this example works with my openssl client and web browser.
https://github.com/espressif/esp-idf/tr ... ssl_server

snahmad75
Posts: 131
Joined: Wed Jan 24, 2018 6:32 pm

Re: RAM usage for mbedtls

Postby snahmad75 » Fri May 18, 2018 9:19 am

Now my client keep connection alive when do post. Still crash. no more connection close error.

Now I am not getting s_ssl_read_record_layer() returned -29312 (-0x7280)

C:/Work/LibDev/esp32/esp-idf/components/mbedtls/library/ssl_tls.c:7042: <= rea
d
D (647522) Socket: rc=1, MBEDTLS_ERR_SSL_WANT_READ=-26880
D (647528) Socket: << accept: sockFd: 4100
D (647534) HttpServerTask: HttpServer that was listening on port 443 has recei
ved a new client connection; sockFd=4100
D (647542) HttpParser: >> parse: socket: fd: 4100
Guru Meditation Error: Core 0 panic'ed (InstrFetchProhibited)
. Exception was unhandled.

snahmad75
Posts: 131
Joined: Wed Jan 24, 2018 6:32 pm

Re: RAM usage for mbedtls

Postby snahmad75 » Fri May 18, 2018 4:12 pm

It look like something to do with Http Parsing. No stack oveflow and plenty of heap. I have not setup eclipse debugger yet. I can try debugging via gnu command line. I am using attached certificate and key string from header file. Can some one try to uses these and test HttpServer with post and enable SSL.

D (29334) Socket: rc=1, MBEDTLS_ERR_SSL_WANT_READ=-26880
D (29340) Socket: << accept: sockFd: 4100
D (29346) HttpServerTask: HttpServer that was listening on port 443 has receiv
ed a new client connection; sockFd=4100
D (29354) HttpParser: >> parse: socket: fd: 4100
Stack free: 10368
Internal Heap free: 74012
Heap free: 8420:74012
Guru Meditation Error: Core 0 panic'ed (InstrFetchProhibited)
. Exception was unhandled.
Attachments
certificate.h
(3.38 KiB) Downloaded 1 time

snahmad75
Posts: 131
Joined: Wed Jan 24, 2018 6:32 pm

Re: RAM usage for mbedtls

Postby snahmad75 » Sat May 19, 2018 7:47 pm

Can someone help me with HttpParser cause crash. I have attached the certificate i am using. can some reproduce at his side using HttpServer class with SSL enable.
httpPostHandler is post handler. Is there alternative Http server routine c or c++ which supports https post method.

void httpPostHandler(HttpRequest* pRequest, HttpResponse* pResponse)
{

std::string http_request = pRequest->getBody();
pResponse->close();
}

class HttpTask: public Task {
void run(void *data) {
ESP_LOGD("http", "Testing http ...");

SSLUtils::setKey(key);
SSLUtils::setCertificate(cert);

HttpServer* pHttpServer = new HttpServer();
pHttpServer->addPathHandler(
HttpRequest::HTTP_METHOD_POST,
"/",
httpPostHandler);

pHttpServer->start(43, true);

return;
}
};

Who is online

Users browsing this forum: No registered users and 4 guests