fix(esp-tls): clean up is_tls flag (IDFGH-16662)#17760
fix(esp-tls): clean up is_tls flag (IDFGH-16662)#17760erkia wants to merge 1 commit intoespressif:masterfrom
Conversation
👋 Hello erkia, we appreciate your contribution to this project! 📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more. 🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project. Click to see more instructions ...
Review and merge process you can expect ...
|
| _esp_tls_net_init(tls); | ||
| tls->is_tls = true; | ||
| } | ||
| _esp_tls_net_init(tls); |
There was a problem hiding this comment.
_esp_tls_net_init() is called by esp_tls_init() anyway, no matter if plain or TLS.
It's only job is to set tls->server_fd.fd = -1; for mbedtls. For wolfssl, it is no-op. So it is safe to call it here always, especially, as tls->sockfd = -1; is forced also.
0af3836 to
17a7169
Compare
|
Hi @erkia , thanks for reporting and creating this issue. Will setting the |
|
Sure, I believe that's also not the correct way as it should be initialised only when tls will be used. |
Description
Commit 2dd280f added a neat feature to support STARTTLS by doing something like this:
However, when doing this,
tls->is_tlsflag is never set totrueinternally (as it is only set in ESP_TLS_INIT state), which prevents callingmbedtls_net_free()here.Luckily, despite its name,
mbedtls_net_free()does not free anything and only does a graceful shutdown of the socket, so it is not a big issue (socket is closed by esp-tls anyway). But as this is the only usecase fortls->is_tlsflag, then it makes sense to clean it up, fixing the small inconsistency in the process.