Skip to content

Commit

Permalink
[https] Get TLS errors from http client
Browse files Browse the repository at this point in the history
  • Loading branch information
KonssnoK committed Dec 19, 2024
1 parent cb3ac74 commit 575b1f6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
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_tls_error(esp_http_client_handle_t client, int *tls_code, int *tls_flags){
if (!client || !tls_code || !tls_flags) {
ESP_LOGE(TAG, "Invalid client handle or params");
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
11 changes: 11 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,17 @@ 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 Get HTTPS client TLS errno
*
* @param[in] client The esp_http_client handle
*
* @return
* - (-1) if invalid argument
* - errno
*/
esp_err_t esp_http_client_get_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 575b1f6

Please sign in to comment.