Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 13 additions & 3 deletions components/esp-tls/esp_tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static ssize_t tcp_write(esp_tls_t *tls, const char *data, size_t datalen)

ssize_t esp_tls_conn_read(esp_tls_t *tls, void *data, size_t datalen)
{
if (!tls) {
if (!tls || !data) {
return -1;
}
return tls->read(tls, (char *)data, datalen);
Expand Down Expand Up @@ -461,7 +461,10 @@ static inline esp_err_t tcp_connect(const char *host, int hostlen, int port, con

static int esp_tls_low_level_conn(const char *hostname, int hostlen, int port, const esp_tls_cfg_t *cfg, esp_tls_t *tls)
{

if (!tls) {
ESP_LOGE(TAG, "empty esp_tls parameter");
return -1;
}
esp_err_t esp_ret;
/* These states are used to keep a tab on connection progress in case of non-blocking connect,
and in case of blocking connect these cases will get executed one after the other */
Expand Down Expand Up @@ -516,6 +519,7 @@ static int esp_tls_low_level_conn(const char *hostname, int hostlen, int port, c
}
}
/* By now, the connection has been established */
ESP_LOGD(TAG, "\ncreate_ssl_handle for host: %s:%d\n", hostname, port);
esp_ret = create_ssl_handle(hostname, hostlen, cfg, tls);
if (esp_ret != ESP_OK) {
ESP_LOGE(TAG, "create_ssl_handle failed");
Expand Down Expand Up @@ -715,11 +719,17 @@ int esp_tls_server_session_create(esp_tls_cfg_server_t *cfg, int sockfd, esp_tls
/**
* @brief Close the server side TLS/SSL connection and free any allocated resources.
*/
#ifdef CONFIG_ESP_TLS_USING_WOLFSSL
int esp_tls_server_session_delete(esp_tls_t *tls)
{
return _esp_tls_server_session_delete(tls);
}
#else
void esp_tls_server_session_delete(esp_tls_t *tls)
{
return _esp_tls_server_session_delete(tls);
}

#endif
ssize_t esp_tls_get_bytes_avail(esp_tls_t *tls)
{
return _esp_tls_get_bytes_avail(tls);
Expand Down
7 changes: 6 additions & 1 deletion components/esp-tls/esp_tls.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "mbedtls/ctr_drbg.h"
#endif
#elif CONFIG_ESP_TLS_USING_WOLFSSL
/* ESP_TLS_HAS_WOLFSSL defined only for versions properly supporting wolfSSL */
#define ESP_TLS_HAS_WOLFSSL
#include "wolfssl/wolfcrypt/settings.h"
#include "wolfssl/ssl.h"
#endif
Expand Down Expand Up @@ -774,8 +776,11 @@ int esp_tls_server_session_create(esp_tls_cfg_server_t *cfg, int sockfd, esp_tls
*
* @param[in] tls pointer to esp_tls_t
*/
#ifdef CONFIG_ESP_TLS_USING_WOLFSSL
int esp_tls_server_session_delete(esp_tls_t *tls);
#else
void esp_tls_server_session_delete(esp_tls_t *tls);

#endif
/**
* @brief Creates a plain TCP connection, returning a valid socket fd on success or an error handle
*
Expand Down