I have MBEDTLS_MEMORY_BUFFER_ALLOC_C defined in my config.h. In my embedded application, I have two SSL sockets, one for the AWS MQTT connection and one for the AWS S3 bucket HTTPS download. Currently I allocate 128KB as a single memory pool. In the processor initialization code, I call mbedtls_memory_buffer_alloc_init() once in the main() before reaching the forever loop.
My problem is that on some rare occasions, I get MBEDTLS_ERR_SSL_INVALID_RECORD (0x7200) during the MQTT CONNECT (i.e., TLS Handshake failure) typically after a previous MQTT session was terminated. When the problem occurs, the device can never be able to recover until after a power cycle. It feels like something is left hanging, and it is rather difficult to troubleshoot because the connection is over the LTE-M cellular network.
I’d like to know if I can split the single “heap” into two, one for MQTT and one for HTTPS. This would allow me to call mbedtls_memory_buffer_alloc_init() to clear the heap independently.
The mbedTLS ported to my project is 2.7.0.