#ifndef H_HTTPS_CLIENT #define H_HTTPS_CLIENT #include #include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_wifi.h" #include "esp_event.h" #include "esp_log.h" #include "esp_system.h" #include "nvs_flash.h" #include "esp_netif.h" #include "lwip/err.h" #include "lwip/sockets.h" #include "lwip/sys.h" #include "lwip/netdb.h" #include "lwip/dns.h" #include "mbedtls/platform.h" #include "mbedtls/net_sockets.h" #include "mbedtls/esp_debug.h" #include "mbedtls/ssl.h" #include "mbedtls/entropy.h" #include "mbedtls/ctr_drbg.h" #include "mbedtls/error.h" #include "mbedtls/certs.h" #include "esp_crt_bundle.h" /* Constants that aren't configurable in menuconfig, yet */ //#define CONFIG_OTA_HTTPS_SERVER_COMMON_NAME "ota.hendrikschutter.com" //#define CONFIG_OTA_HTTPS_SERVER_PORT "443" //#define CONFIG_OTA_HTTPS_URL "https://ota.hendrikschutter.com/hello-world.bin" //#define HTTPS_CLIENT_AUTH "b3RhOnB3" //base64("username:password") #define HTTPS_CLIENT_OK 0 #define HTTPS_CLIENT_ERROR -1 #define HTTPS_CLIENT_ERROR_INIT_EMBEDTLS -2 #define HTTPS_CLIENT_ERROR_INIT_CONNECT_TWO_SERVER -3 #define HTTPS_CLIENT_ERROR_INIT_VALIDATE_SERVER -4 #define HTTPS_CLIENT_ERROR_INIT_SEND_REQUEST -5 struct HTTPS_Client { mbedtls_entropy_context entropy; mbedtls_ctr_drbg_context ctr_drbg; mbedtls_ssl_context ssl; mbedtls_x509_crt cacert; mbedtls_ssl_config conf; mbedtls_net_context server_fd; }; typedef int32_t https_client_ret_t; typedef struct HTTPS_Client HTTPS_Client_t; https_client_ret_t https_clientInitialize(); https_client_ret_t https_clientRetrieveData(); https_client_ret_t https_clientDeinitialize(); #endif /* H_HTTPS_CLIENT */