File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ Arduino_ESP32_OTA::Arduino_ESP32_OTA()
5656,_ota_size(0 )
5757,_crc32(0 )
5858,_ca_cert{amazon_root_ca}
59+ ,_ca_cert_bundle{nullptr }
5960{
6061
6162}
@@ -85,6 +86,13 @@ void Arduino_ESP32_OTA::setCACert (const char *rootCA)
8586 }
8687}
8788
89+ void Arduino_ESP32_OTA::setCACertBundle (const uint8_t * bundle)
90+ {
91+ if (bundle != nullptr ) {
92+ _ca_cert_bundle = bundle;
93+ }
94+ }
95+
8896uint8_t Arduino_ESP32_OTA::read_byte_from_network ()
8997{
9098 bool is_http_data_timeout = false ;
@@ -118,7 +126,13 @@ int Arduino_ESP32_OTA::download(const char * ota_url)
118126 port = 80 ;
119127 } else if (url.protocol_ == " https" ) {
120128 _client = new WiFiClientSecure ();
121- static_cast <WiFiClientSecure*>(_client)->setCACert (_ca_cert);
129+ if (_ca_cert != nullptr ) {
130+ static_cast <WiFiClientSecure*>(_client)->setCACert (_ca_cert);
131+ } else if (_ca_cert_bundle != nullptr ) {
132+ static_cast <WiFiClientSecure*>(_client)->setCACertBundle (_ca_cert_bundle);
133+ } else {
134+ DEBUG_VERBOSE (" %s: CA not configured for download client" );
135+ }
122136 port = 443 ;
123137 } else {
124138 DEBUG_ERROR (" %s: Failed to parse OTA URL %s" , __FUNCTION__, ota_url);
Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ class Arduino_ESP32_OTA
8080
8181 Arduino_ESP32_OTA::Error begin ();
8282 void setCACert (const char *rootCA);
83+ void setCACertBundle (const uint8_t * bundle);
8384 int download (const char * ota_url);
8485 uint8_t read_byte_from_network ();
8586 void write_byte_to_flash (uint8_t data);
@@ -93,6 +94,7 @@ class Arduino_ESP32_OTA
9394 size_t _ota_size;
9495 uint32_t _crc32;
9596 const char * _ca_cert;
97+ const uint8_t * _ca_cert_bundle;
9698};
9799
98100#endif /* ARDUINO_ESP32_OTA_H_ */
You can’t perform that action at this time.
0 commit comments