-
Notifications
You must be signed in to change notification settings - Fork 7.2k
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
Make esp_mbedtls_server_session_create async compatible (IDFGH-13606) #14493
base: master
Are you sure you want to change the base?
Conversation
👋 Hello thetek42, 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 ...
|
33a905d
to
07ff5af
Compare
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.
Thanks for the PR @thetek42,
I agree that an async version would be helpful.
So the mbedtls is an internal layer for esp-tls.
It is not supposed to be directly used publicly (outside of esp-tls component)
Instead I think we should create appropriate APIs for the esp-tls layer and use that layer publicly.
if ((ret = esp_mbedtls_server_session_create_start(cfg, sockfd, tls)) != 0) return ret; | ||
while ((ret = esp_mbedtls_server_session_create_continue_async(tls)) != 0) { | ||
if (ret != ESP_TLS_ERR_SSL_WANT_READ && ret != ESP_TLS_ERR_SSL_WANT_WRITE) { |
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.
if ((ret = esp_mbedtls_server_session_create_start(cfg, sockfd, tls)) != 0) return ret; | |
while ((ret = esp_mbedtls_server_session_create_continue_async(tls)) != 0) { | |
if (ret != ESP_TLS_ERR_SSL_WANT_READ && ret != ESP_TLS_ERR_SSL_WANT_WRITE) { | |
if ((ret = esp_mbedtls_server_session_create_start(cfg, sockfd, tls)) != 0) { | |
return ret; | |
} | |
while ((ret = esp_mbedtls_server_session_create_continue_async(tls)) != 0) { | |
if (ret != ESP_TLS_ERR_SSL_WANT_READ && ret != ESP_TLS_ERR_SSL_WANT_WRITE) { |
/** | ||
* @brief Initialization part of esp_mbedtls_server_session_create | ||
*/ | ||
int esp_mbedtls_server_session_create_start(esp_tls_cfg_server_t *cfg, int sockfd, esp_tls_t *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.
int esp_mbedtls_server_session_create_start(esp_tls_cfg_server_t *cfg, int sockfd, esp_tls_t *tls) | |
int esp_mbedtls_server_session_init(esp_tls_cfg_server_t *cfg, int sockfd, esp_tls_t *tls) |
* called in a loop by the user until it returns 0, ESP_TLS_ERR_SSL_WANT_READ | ||
* or ESP_TLS_ERR_SSL_WANT_WRITE | ||
*/ | ||
int esp_mbedtls_server_session_create_continue_async(esp_tls_t *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.
int esp_mbedtls_server_session_create_continue_async(esp_tls_t *tls) | |
int esp_mbedtls_server_session_continue_async(esp_tls_t *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.
Similar change in Header file
This makes
esp_mbedtls_server_session_create
async-friendly by splitting up the function into two parts. This change was originally proposed here in order to make an asynchronous TLS server possible: esp-rs/esp-idf-svc#368 (comment)