From 1b5c4923c43420daf7d62350d7a0540c77c01961 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Wed, 7 Dec 2022 13:50:32 +0200 Subject: [PATCH] Fix conflict with ESP-IDF's esp_crt_bundle Conflict is reproducible if you have both RainMake and WiFiClientSecure included --- libraries/WiFiClientSecure/src/WiFiClientSecure.cpp | 4 ++-- libraries/WiFiClientSecure/src/esp_crt_bundle.c | 6 +++--- libraries/WiFiClientSecure/src/esp_crt_bundle.h | 6 +++--- libraries/WiFiClientSecure/src/ssl_client.cpp | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libraries/WiFiClientSecure/src/WiFiClientSecure.cpp b/libraries/WiFiClientSecure/src/WiFiClientSecure.cpp index 8862ed7ce07..5cd4f7ab615 100644 --- a/libraries/WiFiClientSecure/src/WiFiClientSecure.cpp +++ b/libraries/WiFiClientSecure/src/WiFiClientSecure.cpp @@ -264,10 +264,10 @@ void WiFiClientSecure::setCACert (const char *rootCA) { if (bundle != NULL) { - esp_crt_bundle_set(bundle); + arduino_esp_crt_bundle_set(bundle); _use_ca_bundle = true; } else { - esp_crt_bundle_detach(NULL); + arduino_esp_crt_bundle_detach(NULL); _use_ca_bundle = false; } } diff --git a/libraries/WiFiClientSecure/src/esp_crt_bundle.c b/libraries/WiFiClientSecure/src/esp_crt_bundle.c index 9a555b218d0..82a0708662c 100644 --- a/libraries/WiFiClientSecure/src/esp_crt_bundle.c +++ b/libraries/WiFiClientSecure/src/esp_crt_bundle.c @@ -176,7 +176,7 @@ static esp_err_t esp_crt_bundle_init(const uint8_t *x509_bundle) return ESP_OK; } -esp_err_t esp_crt_bundle_attach(void *conf) +esp_err_t arduino_esp_crt_bundle_attach(void *conf) { esp_err_t ret = ESP_OK; // If no bundle has been set by the user then use the bundle embedded in the binary @@ -199,7 +199,7 @@ esp_err_t esp_crt_bundle_attach(void *conf) return ret; } -void esp_crt_bundle_detach(mbedtls_ssl_config *conf) +void arduino_esp_crt_bundle_detach(mbedtls_ssl_config *conf) { free(s_crt_bundle.crts); s_crt_bundle.crts = NULL; @@ -208,7 +208,7 @@ void esp_crt_bundle_detach(mbedtls_ssl_config *conf) } } -void esp_crt_bundle_set(const uint8_t *x509_bundle) +void arduino_esp_crt_bundle_set(const uint8_t *x509_bundle) { // Free any previously used bundle free(s_crt_bundle.crts); diff --git a/libraries/WiFiClientSecure/src/esp_crt_bundle.h b/libraries/WiFiClientSecure/src/esp_crt_bundle.h index 33fb98b9969..a1d95194af4 100644 --- a/libraries/WiFiClientSecure/src/esp_crt_bundle.h +++ b/libraries/WiFiClientSecure/src/esp_crt_bundle.h @@ -36,7 +36,7 @@ extern "C" { * - ESP_OK if adding certificates was successful. * - Other if an error occured or an action must be taken by the calling process. */ -esp_err_t esp_crt_bundle_attach(void *conf); +esp_err_t arduino_esp_crt_bundle_attach(void *conf); /** @@ -46,7 +46,7 @@ esp_err_t esp_crt_bundle_attach(void *conf); * * @param[in] conf The config struct for the SSL connection. */ -void esp_crt_bundle_detach(mbedtls_ssl_config *conf); +void arduino_esp_crt_bundle_detach(mbedtls_ssl_config *conf); /** @@ -58,7 +58,7 @@ void esp_crt_bundle_detach(mbedtls_ssl_config *conf); * * @param[in] x509_bundle A pointer to the certificate bundle. */ -void esp_crt_bundle_set(const uint8_t *x509_bundle); +void arduino_esp_crt_bundle_set(const uint8_t *x509_bundle); #ifdef __cplusplus diff --git a/libraries/WiFiClientSecure/src/ssl_client.cpp b/libraries/WiFiClientSecure/src/ssl_client.cpp index 4333b3043b8..e1bcbd8939b 100644 --- a/libraries/WiFiClientSecure/src/ssl_client.cpp +++ b/libraries/WiFiClientSecure/src/ssl_client.cpp @@ -191,7 +191,7 @@ int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t p } } else if (useRootCABundle) { log_v("Attaching root CA cert bundle"); - ret = esp_crt_bundle_attach(&ssl_client->ssl_conf); + ret = arduino_esp_crt_bundle_attach(&ssl_client->ssl_conf); if (ret < 0) { return handle_error(ret);