@@ -34,6 +34,7 @@ Arduino_ESP32_OTA::Arduino_ESP32_OTA()
34
34
, _http_client(nullptr )
35
35
,_ca_cert{amazon_root_ca}
36
36
,_ca_cert_bundle{nullptr }
37
+ ,_ca_cert_bundle_size(0 )
37
38
,_magic(0 )
38
39
{
39
40
@@ -83,6 +84,14 @@ void Arduino_ESP32_OTA::setCACertBundle (const uint8_t * bundle)
83
84
}
84
85
}
85
86
87
+ void Arduino_ESP32_OTA::setCACertBundle (const uint8_t * bundle, size_t size)
88
+ {
89
+ if (bundle != nullptr && size != 0 ) {
90
+ _ca_cert_bundle = bundle;
91
+ _ca_cert_bundle_size = size;
92
+ }
93
+ }
94
+
86
95
void Arduino_ESP32_OTA::setMagic (uint32_t magic)
87
96
{
88
97
_magic = magic;
@@ -114,9 +123,17 @@ int Arduino_ESP32_OTA::startDownload(const char * ota_url)
114
123
_client = new WiFiClientSecure ();
115
124
if (_ca_cert != nullptr ) {
116
125
static_cast <WiFiClientSecure*>(_client)->setCACert (_ca_cert);
117
- } else if (_ca_cert_bundle != nullptr ) {
126
+ }
127
+ #if (ESP_ARDUINO_VERSION < ESP_ARDUINO_VERSION_VAL(3, 0, 4))
128
+ else if (_ca_cert_bundle != nullptr ) {
118
129
static_cast <WiFiClientSecure*>(_client)->setCACertBundle (_ca_cert_bundle);
119
- } else {
130
+ }
131
+ #else
132
+ else if (_ca_cert_bundle != nullptr && _ca_cert_bundle_size != 0 ) {
133
+ static_cast <WiFiClientSecure*>(_client)->setCACertBundle (_ca_cert_bundle, _ca_cert_bundle_size);
134
+ }
135
+ #endif
136
+ else {
120
137
DEBUG_VERBOSE (" %s: CA not configured for download client" );
121
138
}
122
139
} else {
0 commit comments