2018-04-16 16:34:39 +02:00
|
|
|
/* Provide SSL/TLS functions to ESP32 with Arduino IDE
|
|
|
|
* by Evandro Copercini - 2017 - Apache 2.0 License
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ARD_SSL_H
|
|
|
|
#define ARD_SSL_H
|
|
|
|
#include "mbedtls/platform.h"
|
|
|
|
#include "mbedtls/net.h"
|
|
|
|
#include "mbedtls/debug.h"
|
|
|
|
#include "mbedtls/ssl.h"
|
|
|
|
#include "mbedtls/entropy.h"
|
|
|
|
#include "mbedtls/ctr_drbg.h"
|
|
|
|
#include "mbedtls/error.h"
|
|
|
|
|
|
|
|
typedef struct sslclient_context {
|
|
|
|
int socket;
|
|
|
|
mbedtls_ssl_context ssl_ctx;
|
|
|
|
mbedtls_ssl_config ssl_conf;
|
|
|
|
|
|
|
|
mbedtls_ctr_drbg_context drbg_ctx;
|
|
|
|
mbedtls_entropy_context entropy_ctx;
|
|
|
|
|
|
|
|
mbedtls_x509_crt ca_cert;
|
|
|
|
mbedtls_x509_crt client_cert;
|
|
|
|
mbedtls_pk_context client_key;
|
2018-11-26 23:25:08 +01:00
|
|
|
|
|
|
|
unsigned long handshake_timeout;
|
2018-04-16 16:34:39 +02:00
|
|
|
} sslclient_context;
|
|
|
|
|
|
|
|
|
|
|
|
void ssl_init(sslclient_context *ssl_client);
|
2020-12-21 00:09:37 +01:00
|
|
|
int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t port, int timeout, const char *rootCABuff, const char *cli_cert, const char *cli_key, const char *pskIdent, const char *psKey, bool insecure);
|
2018-04-16 16:34:39 +02:00
|
|
|
void stop_ssl_socket(sslclient_context *ssl_client, const char *rootCABuff, const char *cli_cert, const char *cli_key);
|
|
|
|
int data_to_read(sslclient_context *ssl_client);
|
2021-03-18 14:02:37 +01:00
|
|
|
int send_ssl_data(sslclient_context *ssl_client, const uint8_t *data, size_t len);
|
2018-04-16 16:34:39 +02:00
|
|
|
int get_ssl_receive(sslclient_context *ssl_client, uint8_t *data, int length);
|
2018-05-14 13:00:40 +02:00
|
|
|
bool verify_ssl_fingerprint(sslclient_context *ssl_client, const char* fp, const char* domain_name);
|
|
|
|
bool verify_ssl_dn(sslclient_context *ssl_client, const char* domain_name);
|
2018-04-16 16:34:39 +02:00
|
|
|
|
|
|
|
#endif
|