mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-05-31 15:41:02 +08:00
feat(esp-tls): update esp-tls from esp-idf
Commit ID: 03d07741
This commit is contained in:
@ -17,8 +17,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <sys/socket.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#if CONFIG_SSL_USING_MBEDTLS
|
||||
#include "esp_err.h"
|
||||
#ifdef CONFIG_ESP_TLS_USING_MBEDTLS
|
||||
#include "mbedtls/platform.h"
|
||||
#include "mbedtls/net_sockets.h"
|
||||
#include "mbedtls/esp_debug.h"
|
||||
@ -27,7 +27,8 @@
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/error.h"
|
||||
#include "mbedtls/certs.h"
|
||||
#else
|
||||
#elif CONFIG_ESP_TLS_USING_WOLFSSL
|
||||
#include "wolfssl/wolfcrypt/settings.h"
|
||||
#include "wolfssl/ssl.h"
|
||||
#endif
|
||||
|
||||
@ -35,10 +36,44 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
ESP_TLS_ERROR_WANT_READ = -2,
|
||||
ESP_TLS_ERROR_WANT_WRITE = -3,
|
||||
} esp_tls_error_t;
|
||||
#define ESP_ERR_ESP_TLS_BASE 0x8000 /*!< Starting number of ESP-TLS error codes */
|
||||
#define ESP_ERR_ESP_TLS_CANNOT_RESOLVE_HOSTNAME (ESP_ERR_ESP_TLS_BASE + 0x01) /*!< Error if hostname couldn't be resolved upon tls connection */
|
||||
#define ESP_ERR_ESP_TLS_CANNOT_CREATE_SOCKET (ESP_ERR_ESP_TLS_BASE + 0x02) /*!< Failed to create socket */
|
||||
#define ESP_ERR_ESP_TLS_UNSUPPORTED_PROTOCOL_FAMILY (ESP_ERR_ESP_TLS_BASE + 0x03) /*!< Unsupported protocol family */
|
||||
#define ESP_ERR_ESP_TLS_FAILED_CONNECT_TO_HOST (ESP_ERR_ESP_TLS_BASE + 0x04) /*!< Failed to connect to host */
|
||||
#define ESP_ERR_ESP_TLS_SOCKET_SETOPT_FAILED (ESP_ERR_ESP_TLS_BASE + 0x05) /*!< failed to set socket option */
|
||||
#define ESP_ERR_MBEDTLS_CERT_PARTLY_OK (ESP_ERR_ESP_TLS_BASE + 0x06) /*!< mbedtls parse certificates was partly successful */
|
||||
#define ESP_ERR_MBEDTLS_CTR_DRBG_SEED_FAILED (ESP_ERR_ESP_TLS_BASE + 0x07) /*!< mbedtls api returned error */
|
||||
#define ESP_ERR_MBEDTLS_SSL_SET_HOSTNAME_FAILED (ESP_ERR_ESP_TLS_BASE + 0x08) /*!< mbedtls api returned error */
|
||||
#define ESP_ERR_MBEDTLS_SSL_CONFIG_DEFAULTS_FAILED (ESP_ERR_ESP_TLS_BASE + 0x09) /*!< mbedtls api returned error */
|
||||
#define ESP_ERR_MBEDTLS_SSL_CONF_ALPN_PROTOCOLS_FAILED (ESP_ERR_ESP_TLS_BASE + 0x0A) /*!< mbedtls api returned error */
|
||||
#define ESP_ERR_MBEDTLS_X509_CRT_PARSE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x0B) /*!< mbedtls api returned error */
|
||||
#define ESP_ERR_MBEDTLS_SSL_CONF_OWN_CERT_FAILED (ESP_ERR_ESP_TLS_BASE + 0x0C) /*!< mbedtls api returned error */
|
||||
#define ESP_ERR_MBEDTLS_SSL_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x0D) /*!< mbedtls api returned error */
|
||||
#define ESP_ERR_MBEDTLS_SSL_WRITE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x0E) /*!< mbedtls api returned error */
|
||||
#define ESP_ERR_MBEDTLS_PK_PARSE_KEY_FAILED (ESP_ERR_ESP_TLS_BASE + 0x0F) /*!< mbedtls api returned failed */
|
||||
#define ESP_ERR_MBEDTLS_SSL_HANDSHAKE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x10) /*!< mbedtls api returned failed */
|
||||
#define ESP_ERR_MBEDTLS_SSL_CONF_PSK_FAILED (ESP_ERR_ESP_TLS_BASE + 0x11) /*!< mbedtls api returned failed */
|
||||
|
||||
#ifdef CONFIG_ESP_TLS_USING_MBEDTLS
|
||||
#define ESP_TLS_ERR_SSL_WANT_READ MBEDTLS_ERR_SSL_WANT_READ
|
||||
#define ESP_TLS_ERR_SSL_WANT_WRITE MBEDTLS_ERR_SSL_WANT_WRITE
|
||||
#define ESP_TLS_ERR_SSL_TIMEOUT MBEDTLS_ERR_SSL_TIMEOUT
|
||||
#elif CONFIG_ESP_TLS_USING_WOLFSSL /* CONFIG_ESP_TLS_USING_MBEDTLS */
|
||||
#define ESP_TLS_ERR_SSL_WANT_READ WOLFSSL_ERROR_WANT_READ
|
||||
#define ESP_TLS_ERR_SSL_WANT_WRITE WOLFSSL_ERROR_WANT_WRITE
|
||||
#define ESP_TLS_ERR_SSL_TIMEOUT WOLFSSL_CBIO_ERR_TIMEOUT
|
||||
#endif /*CONFIG_ESP_TLS_USING_WOLFSSL */
|
||||
typedef struct esp_tls_last_error* esp_tls_error_handle_t;
|
||||
|
||||
/**
|
||||
* @brief Error structure containing relevant errors in case tls error occurred
|
||||
*/
|
||||
typedef struct esp_tls_last_error {
|
||||
esp_err_t last_error; /*!< error code (based on ESP_ERR_ESP_TLS_BASE) of the last occurred error */
|
||||
int esp_tls_error_code; /*!< esp_tls error code from last esp_tls failed api */
|
||||
int esp_tls_flags; /*!< last certification verification flags */
|
||||
} esp_tls_last_error_t;
|
||||
|
||||
/**
|
||||
* @brief ESP-TLS Connection State
|
||||
@ -51,8 +86,32 @@ typedef enum esp_tls_conn_state {
|
||||
ESP_TLS_DONE,
|
||||
} esp_tls_conn_state_t;
|
||||
|
||||
typedef enum esp_tls_role {
|
||||
ESP_TLS_CLIENT = 0,
|
||||
ESP_TLS_SERVER,
|
||||
} esp_tls_role_t;
|
||||
|
||||
/**
|
||||
* @brief ESP-TLS preshared key and hint structure
|
||||
*/
|
||||
typedef struct psk_key_hint {
|
||||
const uint8_t* key; /*!< key in PSK authentication mode in binary format */
|
||||
const size_t key_size; /*!< length of the key */
|
||||
const char* hint; /*!< hint in PSK authentication mode in string format */
|
||||
} psk_hint_key_t;
|
||||
|
||||
/**
|
||||
* @brief ESP-TLS configuration parameters
|
||||
*
|
||||
* @note Note about format of certificates:
|
||||
* - This structure includes certificates of a Certificate Authority, of client or server as well
|
||||
* as private keys, which may be of PEM or DER format. In case of PEM format, the buffer must be
|
||||
* NULL terminated (with NULL character included in certificate size).
|
||||
* - Certificate Authority's certificate may be a chain of certificates in case of PEM format,
|
||||
* but could be only one certificate in case of DER format
|
||||
* - Variables names of certificates and private key buffers and sizes are defined as unions providing
|
||||
* backward compatibility for legacy *_pem_buf and *_pem_bytes names which suggested only PEM format
|
||||
* was supported. It is encouraged to use generic names such as cacert_buf and cacert_bytes.
|
||||
*/
|
||||
typedef struct esp_tls_cfg {
|
||||
const char **alpn_protos; /*!< Application protocols required for HTTP2.
|
||||
@ -61,27 +120,50 @@ typedef struct esp_tls_cfg {
|
||||
The format is length followed by protocol
|
||||
name.
|
||||
For the most common cases the following is ok:
|
||||
"\x02h2"
|
||||
- where the first '2' is the length of the protocol and
|
||||
- the subsequent 'h2' is the protocol name */
|
||||
const char **alpn_protos = { "h2", NULL };
|
||||
- where 'h2' is the protocol name */
|
||||
|
||||
const unsigned char *cacert_pem_buf; /*!< Certificate Authority's certificate in a buffer.
|
||||
This buffer should be NULL terminated */
|
||||
|
||||
unsigned int cacert_pem_bytes; /*!< Size of Certificate Authority certificate
|
||||
pointed to by cacert_pem_buf */
|
||||
union {
|
||||
const unsigned char *cacert_buf; /*!< Certificate Authority's certificate in a buffer.
|
||||
Format may be PEM or DER, depending on mbedtls-support
|
||||
This buffer should be NULL terminated in case of PEM */
|
||||
const unsigned char *cacert_pem_buf; /*!< CA certificate buffer legacy name */
|
||||
};
|
||||
|
||||
const unsigned char *clientcert_pem_buf;/*!< Client certificate in a buffer
|
||||
This buffer should be NULL terminated */
|
||||
|
||||
unsigned int clientcert_pem_bytes; /*!< Size of client certificate pointed to by
|
||||
clientcert_pem_buf */
|
||||
union {
|
||||
unsigned int cacert_bytes; /*!< Size of Certificate Authority certificate
|
||||
pointed to by cacert_buf
|
||||
(including NULL-terminator in case of PEM format) */
|
||||
unsigned int cacert_pem_bytes; /*!< Size of Certificate Authority certificate legacy name */
|
||||
};
|
||||
|
||||
const unsigned char *clientkey_pem_buf; /*!< Client key in a buffer
|
||||
This buffer should be NULL terminated */
|
||||
union {
|
||||
const unsigned char *clientcert_buf; /*!< Client certificate in a buffer
|
||||
Format may be PEM or DER, depending on mbedtls-support
|
||||
This buffer should be NULL terminated in case of PEM */
|
||||
const unsigned char *clientcert_pem_buf; /*!< Client certificate legacy name */
|
||||
};
|
||||
|
||||
unsigned int clientkey_pem_bytes; /*!< Size of client key pointed to by
|
||||
clientkey_pem_buf */
|
||||
union {
|
||||
unsigned int clientcert_bytes; /*!< Size of client certificate pointed to by
|
||||
clientcert_pem_buf
|
||||
(including NULL-terminator in case of PEM format) */
|
||||
unsigned int clientcert_pem_bytes; /*!< Size of client certificate legacy name */
|
||||
};
|
||||
|
||||
union {
|
||||
const unsigned char *clientkey_buf; /*!< Client key in a buffer
|
||||
Format may be PEM or DER, depending on mbedtls-support
|
||||
This buffer should be NULL terminated in case of PEM */
|
||||
const unsigned char *clientkey_pem_buf; /*!< Client key legacy name */
|
||||
};
|
||||
|
||||
union {
|
||||
unsigned int clientkey_bytes; /*!< Size of client key pointed to by
|
||||
clientkey_pem_buf
|
||||
(including NULL-terminator in case of PEM format) */
|
||||
unsigned int clientkey_pem_bytes; /*!< Size of client key legacy name */
|
||||
};
|
||||
|
||||
const unsigned char *clientkey_password;/*!< Client key decryption password string */
|
||||
|
||||
@ -101,13 +183,73 @@ typedef struct esp_tls_cfg {
|
||||
If NULL, server certificate CN must match hostname. */
|
||||
|
||||
bool skip_common_name; /*!< Skip any validation of server certificate CN field */
|
||||
|
||||
const psk_hint_key_t* psk_hint_key; /*!< Pointer to PSK hint and key. if not NULL (and certificates are NULL)
|
||||
then PSK authentication is enabled with configured setup.
|
||||
Important note: the pointer must be valid for connection */
|
||||
|
||||
} esp_tls_cfg_t;
|
||||
|
||||
#ifdef CONFIG_ESP_TLS_SERVER
|
||||
typedef struct esp_tls_cfg_server {
|
||||
const char **alpn_protos; /*!< Application protocols required for HTTP2.
|
||||
If HTTP2/ALPN support is required, a list
|
||||
of protocols that should be negotiated.
|
||||
The format is length followed by protocol
|
||||
name.
|
||||
For the most common cases the following is ok:
|
||||
const char **alpn_protos = { "h2", NULL };
|
||||
- where 'h2' is the protocol name */
|
||||
|
||||
union {
|
||||
const unsigned char *cacert_buf; /*!< Client CA certificate in a buffer.
|
||||
This buffer should be NULL terminated */
|
||||
const unsigned char *cacert_pem_buf; /*!< Client CA certificate legacy name */
|
||||
};
|
||||
|
||||
union {
|
||||
unsigned int cacert_bytes; /*!< Size of client CA certificate
|
||||
pointed to by cacert_pem_buf */
|
||||
unsigned int cacert_pem_bytes; /*!< Size of client CA certificate legacy name */
|
||||
};
|
||||
|
||||
union {
|
||||
const unsigned char *servercert_buf; /*!< Server certificate in a buffer
|
||||
This buffer should be NULL terminated */
|
||||
const unsigned char *servercert_pem_buf; /*!< Server certificate legacy name */
|
||||
};
|
||||
|
||||
union {
|
||||
unsigned int servercert_bytes; /*!< Size of server certificate pointed to by
|
||||
servercert_pem_buf */
|
||||
unsigned int servercert_pem_bytes; /*!< Size of server certificate legacy name */
|
||||
};
|
||||
|
||||
union {
|
||||
const unsigned char *serverkey_buf; /*!< Server key in a buffer
|
||||
This buffer should be NULL terminated */
|
||||
const unsigned char *serverkey_pem_buf; /*!< Server key legacy name */
|
||||
};
|
||||
|
||||
union {
|
||||
unsigned int serverkey_bytes; /*!< Size of server key pointed to by
|
||||
serverkey_pem_buf */
|
||||
unsigned int serverkey_pem_bytes; /*!< Size of server key legacy name */
|
||||
};
|
||||
|
||||
const unsigned char *serverkey_password; /*!< Server key decryption password string */
|
||||
|
||||
unsigned int serverkey_password_len; /*!< String length of the password pointed to by
|
||||
serverkey_password */
|
||||
|
||||
} esp_tls_cfg_server_t;
|
||||
#endif /* ! CONFIG_ESP_TLS_SERVER */
|
||||
|
||||
/**
|
||||
* @brief ESP-TLS Connection Handle
|
||||
*/
|
||||
typedef struct esp_tls {
|
||||
#if CONFIG_SSL_USING_MBEDTLS
|
||||
#ifdef CONFIG_ESP_TLS_USING_MBEDTLS
|
||||
mbedtls_ssl_context ssl; /*!< TLS/SSL context */
|
||||
|
||||
mbedtls_entropy_context entropy; /*!< mbedTLS entropy context structure */
|
||||
@ -130,16 +272,22 @@ typedef struct esp_tls {
|
||||
|
||||
mbedtls_pk_context clientkey; /*!< Container for the private key of the client
|
||||
certificate */
|
||||
#else
|
||||
WOLFSSL_CTX *ctx;
|
||||
WOLFSSL *ssl;
|
||||
#ifdef CONFIG_ESP_TLS_SERVER
|
||||
mbedtls_x509_crt servercert; /*!< Container for the X.509 server certificate */
|
||||
|
||||
mbedtls_pk_context serverkey; /*!< Container for the private key of the server
|
||||
certificate */
|
||||
#endif
|
||||
#elif CONFIG_ESP_TLS_USING_WOLFSSL
|
||||
void *priv_ctx;
|
||||
void *priv_ssl;
|
||||
#endif
|
||||
int sockfd; /*!< Underlying socket file descriptor. */
|
||||
|
||||
ssize_t (*_read)(struct esp_tls *tls, char *data, size_t datalen); /*!< Callback function for reading data from TLS/SSL
|
||||
ssize_t (*read)(struct esp_tls *tls, char *data, size_t datalen); /*!< Callback function for reading data from TLS/SSL
|
||||
connection. */
|
||||
|
||||
ssize_t (*_write)(struct esp_tls *tls, const char *data, size_t datalen); /*!< Callback function for writing data to TLS/SSL
|
||||
ssize_t (*write)(struct esp_tls *tls, const char *data, size_t datalen); /*!< Callback function for writing data to TLS/SSL
|
||||
connection. */
|
||||
|
||||
esp_tls_conn_state_t conn_state; /*!< ESP-TLS Connection state */
|
||||
@ -149,23 +297,70 @@ typedef struct esp_tls {
|
||||
fd_set wset; /*!< write file descriptors */
|
||||
|
||||
bool is_tls; /*!< indicates connection type (TLS or NON-TLS) */
|
||||
|
||||
esp_tls_role_t role; /*!< esp-tls role
|
||||
- ESP_TLS_CLIENT
|
||||
- ESP_TLS_SERVER */
|
||||
|
||||
esp_tls_error_handle_t error_handle; /*!< handle to error descriptor */
|
||||
|
||||
} esp_tls_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Create TLS connection
|
||||
*
|
||||
* This function allocates and initializes esp-tls structure handle.
|
||||
*
|
||||
* @return tls Pointer to esp-tls as esp-tls handle if successfully initialized,
|
||||
* NULL if allocation error
|
||||
*/
|
||||
esp_tls_t *esp_tls_init(void);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Create a new blocking TLS/SSL connection
|
||||
*
|
||||
* This function establishes a TLS/SSL connection with the specified host in blocking manner.
|
||||
*
|
||||
*
|
||||
* Note: This API is present for backward compatibility reasons. Alternative function
|
||||
* with the same functionality is `esp_tls_conn_new_sync` (and its asynchronous version
|
||||
* `esp_tls_conn_new_async`)
|
||||
*
|
||||
* @param[in] hostname Hostname of the host.
|
||||
* @param[in] hostlen Length of hostname.
|
||||
* @param[in] port Port number of the host.
|
||||
* @param[in] cfg TLS configuration as esp_tls_cfg_t. If you wish to open
|
||||
* @param[in] cfg TLS configuration as esp_tls_cfg_t. If you wish to open
|
||||
* non-TLS connection, keep this NULL. For TLS connection,
|
||||
* a pass pointer to esp_tls_cfg_t. At a minimum, this
|
||||
* structure should be zero-initialized.
|
||||
*
|
||||
* @return pointer to esp_tls_t, or NULL if connection couldn't be opened.
|
||||
*/
|
||||
esp_tls_t *esp_tls_conn_new(const char *hostname, int hostlen, int port, const esp_tls_cfg_t *cfg);
|
||||
esp_tls_t *esp_tls_conn_new(const char *hostname, int hostlen, int port, const esp_tls_cfg_t *cfg) __attribute__ ((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Create a new blocking TLS/SSL connection
|
||||
*
|
||||
* This function establishes a TLS/SSL connection with the specified host in blocking manner.
|
||||
*
|
||||
* @param[in] hostname Hostname of the host.
|
||||
* @param[in] hostlen Length of hostname.
|
||||
* @param[in] port Port number of the host.
|
||||
* @param[in] cfg TLS configuration as esp_tls_cfg_t. If you wish to open
|
||||
* non-TLS connection, keep this NULL. For TLS connection,
|
||||
* a pass pointer to esp_tls_cfg_t. At a minimum, this
|
||||
* structure should be zero-initialized.
|
||||
* @param[in] tls Pointer to esp-tls as esp-tls handle.
|
||||
*
|
||||
* @return
|
||||
* - -1 If connection establishment fails.
|
||||
* - 1 If connection establishment is successful.
|
||||
* - 0 Reserved for connection state is in progress.
|
||||
*/
|
||||
int esp_tls_conn_new_sync(const char *hostname, int hostlen, int port, const esp_tls_cfg_t *cfg, esp_tls_t *tls);
|
||||
|
||||
/**
|
||||
* @brief Create a new blocking TLS/SSL connection with a given "HTTP" url
|
||||
@ -234,7 +429,7 @@ int esp_tls_conn_http_new_async(const char *url, const esp_tls_cfg_t *cfg, esp_t
|
||||
*/
|
||||
static inline ssize_t esp_tls_conn_write(esp_tls_t *tls, const void *data, size_t datalen)
|
||||
{
|
||||
return tls->_write(tls, (char *)data, datalen);
|
||||
return tls->write(tls, (char *)data, datalen);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -254,7 +449,7 @@ static inline ssize_t esp_tls_conn_write(esp_tls_t *tls, const void *data, size_
|
||||
*/
|
||||
static inline ssize_t esp_tls_conn_read(esp_tls_t *tls, void *data, size_t datalen)
|
||||
{
|
||||
return tls->_read(tls, (char *)data, datalen);
|
||||
return tls->read(tls, (char *)data, datalen);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -280,7 +475,7 @@ void esp_tls_conn_delete(esp_tls_t *tls);
|
||||
* - bytes available in the application data
|
||||
* record read buffer
|
||||
*/
|
||||
size_t esp_tls_get_bytes_avail(esp_tls_t *tls);
|
||||
ssize_t esp_tls_get_bytes_avail(esp_tls_t *tls);
|
||||
|
||||
/**
|
||||
* @brief Create a global CA store, initially empty.
|
||||
@ -293,7 +488,7 @@ size_t esp_tls_get_bytes_avail(esp_tls_t *tls);
|
||||
* - ESP_OK if creating global CA store was successful.
|
||||
* - ESP_ERR_NO_MEM if an error occured when allocating the mbedTLS resources.
|
||||
*/
|
||||
esp_err_t esp_tls_init_global_ca_store();
|
||||
esp_err_t esp_tls_init_global_ca_store(void);
|
||||
|
||||
/**
|
||||
* @brief Set the global CA store with the buffer provided in pem format.
|
||||
@ -314,6 +509,32 @@ esp_err_t esp_tls_init_global_ca_store();
|
||||
*/
|
||||
esp_err_t esp_tls_set_global_ca_store(const unsigned char *cacert_pem_buf, const unsigned int cacert_pem_bytes);
|
||||
|
||||
/**
|
||||
* @brief Free the global CA store currently being used.
|
||||
*
|
||||
* The memory being used by the global CA store to store all the parsed certificates is
|
||||
* freed up. The application can call this API if it no longer needs the global CA store.
|
||||
*/
|
||||
void esp_tls_free_global_ca_store(void);
|
||||
|
||||
/**
|
||||
* @brief Returns last error in esp_tls with detailed mbedtls related error codes.
|
||||
* The error information is cleared internally upon return
|
||||
*
|
||||
* @param[in] h esp-tls error handle.
|
||||
* @param[out] esp_tls_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_ERR_INVALID_STATE 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_tls_get_and_clear_last_error(esp_tls_error_handle_t h, int *esp_tls_code, int *esp_tls_flags);
|
||||
|
||||
#if CONFIG_ESP_TLS_USING_MBEDTLS
|
||||
/**
|
||||
* @brief Get the pointer to the global CA store currently being used.
|
||||
*
|
||||
@ -326,16 +547,36 @@ esp_err_t esp_tls_set_global_ca_store(const unsigned char *cacert_pem_buf, const
|
||||
* - Pointer to the global CA store currently being used if successful.
|
||||
* - NULL if there is no global CA store set.
|
||||
*/
|
||||
void *esp_tls_get_global_ca_store();
|
||||
mbedtls_x509_crt *esp_tls_get_global_ca_store(void);
|
||||
|
||||
#ifdef CONFIG_ESP_TLS_SERVER
|
||||
/**
|
||||
* @brief Create TLS/SSL server session
|
||||
*
|
||||
* This function creates a TLS/SSL server context for already accepted client connection
|
||||
* and performs TLS/SSL handshake with the client
|
||||
*
|
||||
* @param[in] cfg Pointer to esp_tls_cfg_server_t
|
||||
* @param[in] sockfd FD of accepted connection
|
||||
* @param[out] tls Pointer to allocated esp_tls_t
|
||||
*
|
||||
* @return
|
||||
* - 0 if successful
|
||||
* - <0 in case of error
|
||||
*
|
||||
*/
|
||||
int esp_tls_server_session_create(esp_tls_cfg_server_t *cfg, int sockfd, esp_tls_t *tls);
|
||||
|
||||
/**
|
||||
* @brief Free the global CA store currently being used.
|
||||
* @brief Close the server side TLS/SSL connection and free any allocated resources.
|
||||
*
|
||||
* The memory being used by the global CA store to store all the parsed certificates is
|
||||
* freed up. The application can call this API if it no longer needs the global CA store.
|
||||
* This function should be called to close each tls connection opened with esp_tls_server_session_create()
|
||||
*
|
||||
* @param[in] tls pointer to esp_tls_t
|
||||
*/
|
||||
void esp_tls_free_global_ca_store();
|
||||
|
||||
void esp_tls_server_session_delete(esp_tls_t *tls);
|
||||
#endif /* ! CONFIG_ESP_TLS_SERVER */
|
||||
#endif /* CONFIG_ESP_TLS_USING_MBEDTLS */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Reference in New Issue
Block a user