I have verified that I can connect to GMAIL's IMAP adapter with the openssl s_client, and issue commands, on my development PC.
However, when setting up a connection using ESP-TLS, I am getting a connection that, even though I am using esp_tls_connection_new_sync() I seem to be getting a connection that returns successful, yet the conn_status seems to be stuck in init.
I have set up cfg as a mostly empty struct, with the exception that I am using the embeddable Root CA bundle:
(and yes, the root CA bundle has been enabled in the SDK menuconfig)
Code: Select all
memset(&cfg, 0, sizeof(esp_tls_cfg_t));
cfg.crt_bundle_attach = esp_crt_bundle_attach; // ensure we use root CA bundle
conn = nullptr;
Code: Select all
/**
* @brief Open connection to the protocol using URL
* @param urlParser The URL object passed in to open.
* @param cmdFrame The command frame to extract aux1/aux2/etc.
*/
bool NetworkProtocolIMAP::open(EdUrlParser *urlParser, cmdFrame_t *cmdFrame)
{
memset(buf, 0, sizeof(buf));
Debug_printf("Opening SSL connection to %s\n", urlParser->hostName.c_str());
conn = esp_tls_init();
int connStatus = esp_tls_conn_new_sync(urlParser->hostName.c_str(), urlParser->hostName.length(), 993, &cfg, conn);
if (conn == nullptr)
{
Debug_printf("Could not open connection.\n");
error = NETWORK_ERROR_COULD_NOT_ALLOCATE_BUFFERS;
return true;
}
else if (connStatus == -1)
{
Debug_printf("Connection failed\n");
error = NETWORK_ERROR_COULD_NOT_ALLOCATE_BUFFERS;
return true;
}
else if (connStatus == 1)
{
Debug_printf("Connection successful.\n");
}
fnSystem.delay(10000);
Debug_printf("conn state is: ");
switch (conn->conn_state)
{
case ESP_TLS_INIT:
Debug_printf("init\n");
break;
case ESP_TLS_CONNECTING:
Debug_printf("connecting\n");
break;
case ESP_TLS_HANDSHAKE:
Debug_printf("handshake\n");
break;
case ESP_TLS_FAIL:
Debug_printf("fail\n");
break;
case ESP_TLS_DONE:
Debug_printf("Done\n");
break;
}
ssize_t s = esp_tls_conn_read(conn, buf, sizeof(buf)); // CRASHES HERE
Debug_printf("Data read: %s\n",buf);
return false;
}
Code: Select all
CF: 71 4f 0c 00 cc
sioNetwork::sio_process 0x4f 'O': 0x0c, 0x00
sioNetwork::sio_open()
ACK!
<-SIO read 256 bytes
ACK!
sioNetwork::parseURL(N:IMAP://IMAP.GMAIL.COM/)
sioNetwork::parseURL transformed to (N:IMAP://IMAP.GMAIL.COM/, IMAP://IMAP.GMAIL.COM/)
Parse and instantiate protocol: N:IMAP://IMAP.GMAIL.COM/
NetworkProtocol::ctor()
NetworkProtocolIMAP::ctor
sioNetwork::open_protocol() - Protocol IMAP opened.
Opening SSL connection to IMAP.GMAIL.COM
Connection successful.
conn state is: init
Guru Meditation Error: Core 1 panic'ed (InstrFetchProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x00000060 PS : 0x00060330 A0 : 0x800deb7b A1 : 0x3fff65a0
A2 : 0x00000060 A3 : 0x61747320 A4 : 0x3fffc008 A5 : 0x3fff6590
A6 : 0x00000008 A7 : 0x00000000 A8 : 0x80213d14 A9 : 0x3fff6550
A10 : 0x3fffc118 A11 : 0x3fffc008 A12 : 0x00000100 A13 : 0x3fffbfc8
A14 : 0x3fffc118 A15 : 0x3fffbe58 SAR : 0x00000008 EXCCAUSE: 0x00000014
EXCVADDR: 0x00000060 LBEG : 0x40093232 LEND : 0x4009323d LCOUNT : 0x00000000
Backtrace:0x0000005d:0x3fff65a0 |<-CORRUPTED
#0 0x0000005d:0x3fff65a0 in ?? ??:0
ELF file SHA256: 768576170599e239
Rebooting...
-Thom