diff --git a/src/Arduino_ESP32_OTA.cpp b/src/Arduino_ESP32_OTA.cpp index 39dd327..799e4f3 100644 --- a/src/Arduino_ESP32_OTA.cpp +++ b/src/Arduino_ESP32_OTA.cpp @@ -34,6 +34,7 @@ Arduino_ESP32_OTA::Arduino_ESP32_OTA() , _http_client(nullptr) ,_ca_cert{amazon_root_ca} ,_ca_cert_bundle{nullptr} +,_ca_cert_budle_size(0) ,_magic(0) { @@ -76,12 +77,22 @@ void Arduino_ESP32_OTA::setCACert (const char *rootCA) } } +#if (ESP_ARDUINO_VERSION < ESP_ARDUINO_VERSION_VAL(3, 0, 4)) void Arduino_ESP32_OTA::setCACertBundle (const uint8_t * bundle) { if(bundle != nullptr) { _ca_cert_bundle = bundle; } } +#else +void Arduino_ESP32_OTA::setCACertBundle (const uint8_t * bundle, size_t size) +{ + if(bundle != nullptr && size != 0) { + _ca_cert_bundle = bundle; + _ca_cert_budle_size = size; + } +} +#endif void Arduino_ESP32_OTA::setMagic(uint32_t magic) { @@ -115,7 +126,11 @@ int Arduino_ESP32_OTA::startDownload(const char * ota_url) if (_ca_cert != nullptr) { static_cast(_client)->setCACert(_ca_cert); } else if (_ca_cert_bundle != nullptr) { +#if (ESP_ARDUINO_VERSION < ESP_ARDUINO_VERSION_VAL(3, 0, 4)) static_cast(_client)->setCACertBundle(_ca_cert_bundle); +#else + static_cast(_client)->setCACertBundle(_ca_cert_bundle, _ca_cert_budle_size); +#endif } else { DEBUG_VERBOSE("%s: CA not configured for download client"); } diff --git a/src/Arduino_ESP32_OTA.h b/src/Arduino_ESP32_OTA.h index f82c6e1..6202ef2 100644 --- a/src/Arduino_ESP32_OTA.h +++ b/src/Arduino_ESP32_OTA.h @@ -24,6 +24,7 @@ #include #include +#include #include "decompress/utility.h" #include "decompress/lzss.h" #include @@ -87,7 +88,11 @@ class Arduino_ESP32_OTA Arduino_ESP32_OTA::Error begin(uint32_t magic = ARDUINO_ESP32_OTA_MAGIC); void setMagic(uint32_t magic); void setCACert(const char *rootCA); +#if (ESP_ARDUINO_VERSION < ESP_ARDUINO_VERSION_VAL(3, 0, 4)) void setCACertBundle(const uint8_t * bundle); +#else + void setCACertBundle (const uint8_t * bundle, size_t size); +#endif // blocking version for the download // returns the size of the downloaded binary @@ -151,6 +156,7 @@ class Arduino_ESP32_OTA HttpClient* _http_client; const char * _ca_cert; const uint8_t * _ca_cert_bundle; + size_t _ca_cert_budle_size; uint32_t _magic; void clean();