-
Notifications
You must be signed in to change notification settings - Fork 8k
fix(esp-tls): clean up is_tls flag (IDFGH-16662) #17760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_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.