Page 1 of 1

mbedTLS hangs during handshake

Posted: Wed Mar 15, 2017 7:17 am
by BuddyCasino
When I try to connect to the Amazon Alexa endpoint, often (but not always!) the connection seems to hang in the handshake phase, then proceed after well over a minute.

Other endpoints like https://http2.golang.org/ do not exhibit this behaviour.

Interestingly "nmap --script ssl-enum-ciphers -p 443 avs-alexa-eu.amazon.com" also seems to have trouble with Amazon, sometimes not finding any cypher.

I have no idea how to debug this.

Re: mbedTLS hangs during handshake

Posted: Wed Mar 15, 2017 7:44 am
by ESP_Angus
Getting a dump of the TCP session is probably the first thing to try. Although you won't be able to view the contents of the TLS messages, you can see what type of message they are and see where the pauses happen and if anything strange is happening (retransmits at the TCP layer, failed negotiation attempts, etc.)

There are various ways to get a TCP session capture like this. I do it by addding a second USB WiFi adapter to my laptop, setting it up as an access point which NATs out to my "real" network. Then I can connect the ESP32 to the USB adapter access point, and capture traffic as it goes through. Or you could probably do it on a single WiFi network by setting up a socat tunnel (or something similar) and connecting the ESP32 to the tunnel, which then relays the TCP stream to the Alexa endpoint.


Angus

Re: mbedTLS hangs during handshake

Posted: Wed Mar 15, 2017 2:53 pm
by BuddyCasino
Thanks, I'll try that!
Is there a way to get a core dump of the ESP using my JTAG debugger?

Re: mbedTLS hangs during handshake

Posted: Thu Mar 16, 2017 6:22 am
by ChrisHolza
Hi Buddy,

is it possibly related to this one: https://github.com/espressif/esp-idf/issues/139?

I'm still having trouble there, would be great if anyone could confirm.

Other than that, have you turned on "Component Config -> mbedTLS -> Disable hardware MPI (bignum) acceleration" ?

Re: mbedTLS hangs during handshake

Posted: Fri Mar 31, 2017 8:52 am
by BuddyCasino
Looks like the newest version fixed it, no need to disable hw acceleration - thanks for the heads up! This was driving me insane.