Skip to content
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

feat(https): Get TLS errors from http client (IDFGH-14265) #15059

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(https): Get TLS errors from http client
update PR

update mr
  • Loading branch information
KonssnoK committed Jan 7, 2025
commit 7dcbf4319a837ded1038b019b11a79cb446d2993
12 changes: 12 additions & 0 deletions components/esp_http_client/esp_http_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,18 @@ int esp_http_client_get_errno(esp_http_client_handle_t client)
return esp_transport_get_errno(client->transport);
}

esp_err_t esp_http_client_get_and_clear_last_tls_error(esp_http_client_handle_t client, int *tls_code, int *tls_flags){
if (!client) {
ESP_LOGE(TAG, "Invalid client handle");
return ESP_FAIL;
}
return esp_tls_get_and_clear_last_error(
KonssnoK marked this conversation as resolved.
Show resolved Hide resolved
esp_transport_get_error_handle(client->transport),
tls_code,
tls_flags
);
KonssnoK marked this conversation as resolved.
Show resolved Hide resolved
}

esp_err_t esp_http_client_set_method(esp_http_client_handle_t client, esp_http_client_method_t method)
{
client->connection_info.method = method;
Expand Down
17 changes: 17 additions & 0 deletions components/esp_http_client/include/esp_http_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,23 @@ esp_err_t esp_http_client_set_user_data(esp_http_client_handle_t client, void *d
*/
int esp_http_client_get_errno(esp_http_client_handle_t client);

/**
* @brief Returns last error in esp_tls with detailed mbedtls related error codes.
* The error information is cleared internally upon return
*
* @param[in] client The esp_http_client handle
* @param[out] esp_tls_error_code last error code returned from mbedtls api (set to zero if none)
* This pointer could be NULL if caller does not care about esp_tls_code
* @param[out] esp_tls_flags last certification verification flags (set to zero if none)
* This pointer could be NULL if caller does not care about esp_tls_code
*
* @return
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update the return type as per the API.

* - ESP_FAIL if invalid parameters
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* - ESP_FAIL if invalid parameters
* - ESP_ERR_INVALID_STATE if invalid parameters

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm it actually returns ESP_FAIL.. is ESP_ERR_INVALID_STATE a mask for that?

* - ESP_OK (0) if no error occurred
* - specific error code (based on ESP_ERR_ESP_TLS_BASE) otherwise
*/
esp_err_t esp_http_client_get_and_clear_last_tls_error(esp_http_client_handle_t client, int *esp_tls_error_code, int *esp_tls_flags);

/**
* @brief Set http request method
*
Expand Down
Loading