File tree Expand file tree Collapse file tree 4 files changed +24
-1
lines changed
examples/system/ota/advanced_https_ota Expand file tree Collapse file tree 4 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,6 @@ idf_component_register(SRCS "advanced_https_ota_example.c" "ble_helper/bluedroid
33 INCLUDE_DIRS "." "./ble_helper/include/"
44 PRIV_REQUIRES esp_http_client app_update esp_https_ota
55 nvs_flash esp_netif esp_wifi efuse bt
6- protocomm
6+ protocomm mbedtls
77 # Embed the server root certificate into the final binary
88 EMBED_TXTFILES ${project_dir} /server_certs/ca_cert.pem)
Original file line number Diff line number Diff line change @@ -53,4 +53,13 @@ menu "Example Configuration"
5353 This option allows one to configure the OTA process to resume downloading the OTA image
5454 from where it left off in case of an error or reboot.
5555
56+ config EXAMPLE_USE_CERT_BUNDLE
57+ bool "Enable certificate bundle"
58+ default y
59+ depends on MBEDTLS_CERTIFICATE_BUNDLE
60+ help
61+ Enable trusted root certificate bundle. This approach allows to have
62+ OTA updates functional with any public server without requirement
63+ to explicitly add its server certificate.
64+
5665endmenu
Original file line number Diff line number Diff line change 2222#include "nvs_flash.h"
2323#include "protocol_examples_common.h"
2424
25+
26+ #ifdef CONFIG_EXAMPLE_USE_CERT_BUNDLE
27+ #include "esp_crt_bundle.h"
28+ #endif
29+
2530#if CONFIG_BOOTLOADER_APP_ANTI_ROLLBACK
2631#include "esp_efuse.h"
2732#endif
@@ -221,7 +226,11 @@ void advanced_ota_example_task(void *pvParameter)
221226 esp_err_t ota_finish_err = ESP_OK ;
222227 esp_http_client_config_t config = {
223228 .url = CONFIG_EXAMPLE_FIRMWARE_UPGRADE_URL ,
229+ #ifdef CONFIG_EXAMPLE_USE_CERT_BUNDLE
230+ .crt_bundle_attach = esp_crt_bundle_attach ,
231+ #else
224232 .cert_pem = (char * )server_cert_pem_start ,
233+ #endif
225234 .timeout_ms = CONFIG_EXAMPLE_OTA_RECV_TIMEOUT ,
226235 .keep_alive_enable = true,
227236#ifdef CONFIG_EXAMPLE_ENABLE_PARTIAL_HTTP_DOWNLOAD
Original file line number Diff line number Diff line change 22# partition table layout, with a 4MB flash size
33CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
44CONFIG_PARTITION_TABLE_TWO_OTA_LARGE=y
5+
6+ # Certificate bundle configuration
7+ CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN=y
8+ CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y
9+ CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH="server_certs/ca_cert.pem"
You can’t perform that action at this time.
0 commit comments