Skip to content

Commit

Permalink
feat(https): Get TLS errors from http client
Browse files Browse the repository at this point in the history
update PR

update mr

Update components/esp_http_client/esp_http_client.c

Co-authored-by: Nilesh Kale <[email protected]>
  • Loading branch information
KonssnoK and nileshkale123 committed Jan 14, 2025
1 parent cb3ac74 commit dca099d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
8 changes: 8 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,14 @@ 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(esp_transport_get_error_handle(client->transport), tls_code, tls_flags);
}

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
* - ESP_FAIL if invalid parameters
* - 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

0 comments on commit dca099d

Please sign in to comment.