File tree 2 files changed +17
-1
lines changed
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()
56
56
,_ota_size(0 )
57
57
,_crc32(0 )
58
58
,_ca_cert{amazon_root_ca}
59
+ ,_ca_cert_bundle{nullptr }
59
60
{
60
61
61
62
}
@@ -85,6 +86,13 @@ void Arduino_ESP32_OTA::setCACert (const char *rootCA)
85
86
}
86
87
}
87
88
89
+ void Arduino_ESP32_OTA::setCACertBundle (const uint8_t * bundle)
90
+ {
91
+ if (bundle != nullptr ) {
92
+ _ca_cert_bundle = bundle;
93
+ }
94
+ }
95
+
88
96
uint8_t Arduino_ESP32_OTA::read_byte_from_network ()
89
97
{
90
98
bool is_http_data_timeout = false ;
@@ -118,7 +126,13 @@ int Arduino_ESP32_OTA::download(const char * ota_url)
118
126
port = 80 ;
119
127
} else if (url.protocol_ == " https" ) {
120
128
_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
+ }
122
136
port = 443 ;
123
137
} else {
124
138
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
80
80
81
81
Arduino_ESP32_OTA::Error begin ();
82
82
void setCACert (const char *rootCA);
83
+ void setCACertBundle (const uint8_t * bundle);
83
84
int download (const char * ota_url);
84
85
uint8_t read_byte_from_network ();
85
86
void write_byte_to_flash (uint8_t data);
@@ -93,6 +94,7 @@ class Arduino_ESP32_OTA
93
94
size_t _ota_size;
94
95
uint32_t _crc32;
95
96
const char * _ca_cert;
97
+ const uint8_t * _ca_cert_bundle;
96
98
};
97
99
98
100
#endif /* ARDUINO_ESP32_OTA_H_ */
You can’t perform that action at this time.
0 commit comments