Skip to content

Commit 1472c21

Browse files
authored
Merge branch 'master' into ci/refactor
2 parents f7cc27e + dc5bd38 commit 1472c21

File tree

11 files changed

+139
-29
lines changed

11 files changed

+139
-29
lines changed

Diff for: .github/scripts/on-release.sh

+22-4
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ find "$PKG_DIR" -name '*.git*' -type f -delete
216216
##
217217
RVTC_NAME="riscv32-esp-elf-gcc"
218218
RVTC_NEW_NAME="esp-rv32"
219+
X32TC_NAME="xtensa-esp32-elf-gcc"
220+
X32TC_NEW_NAME="esp-x32"
221+
XS2TC_NAME="xtensa-esp32s2-elf-gcc"
222+
XS2TC_NEW_NAME="esp-xs2"
223+
XS3TC_NAME="xtensa-esp32s3-elf-gcc"
224+
XS3TC_NEW_NAME="esp-xs3"
219225

220226
# Replace tools locations in platform.txt
221227
echo "Generating platform.txt..."
@@ -224,9 +230,9 @@ sed "s/version=.*/version=$RELEASE_TAG/g" | \
224230
sed 's/tools\.esp32-arduino-libs\.path\.windows=.*//g' | \
225231
sed 's/{runtime\.platform\.path}.tools.esp32-arduino-libs/\{runtime.tools.esp32-arduino-libs.path\}/g' | \
226232
sed 's/{runtime\.platform\.path}.tools.xtensa-esp-elf-gdb/\{runtime.tools.xtensa-esp-elf-gdb.path\}/g' | \
227-
sed 's/{runtime\.platform\.path}.tools.xtensa-esp32-elf/\{runtime.tools.xtensa-esp32-elf-gcc.path\}/g' | \
228-
sed 's/{runtime\.platform\.path}.tools.xtensa-esp32s2-elf/\{runtime.tools.xtensa-esp32s2-elf-gcc.path\}/g' | \
229-
sed 's/{runtime\.platform\.path}.tools.xtensa-esp32s3-elf/\{runtime.tools.xtensa-esp32s3-elf-gcc.path\}/g' | \
233+
sed "s/{runtime\.platform\.path}.tools.xtensa-esp32-elf/\\{runtime.tools.$X32TC_NEW_NAME.path\\}/g" | \
234+
sed "s/{runtime\.platform\.path}.tools.xtensa-esp32s2-elf/\\{runtime.tools.$XS2TC_NEW_NAME.path\\}/g" | \
235+
sed "s/{runtime\.platform\.path}.tools.xtensa-esp32s3-elf/\\{runtime.tools.$XS3TC_NEW_NAME.path\\}/g" | \
230236
sed 's/{runtime\.platform\.path}.tools.riscv32-esp-elf-gdb/\{runtime.tools.riscv32-esp-elf-gdb.path\}/g' | \
231237
sed "s/{runtime\.platform\.path}.tools.riscv32-esp-elf/\\{runtime.tools.$RVTC_NEW_NAME.path\\}/g" | \
232238
sed 's/{runtime\.platform\.path}.tools.esptool/\{runtime.tools.esptool_py.path\}/g' | \
@@ -342,7 +348,19 @@ rvtc_jq_arg="\
342348
(.packages[0].platforms[0].toolsDependencies[] | select(.name==\"$RVTC_NAME\")).version = \"$RVTC_VERSION\" |\
343349
(.packages[0].platforms[0].toolsDependencies[] | select(.name==\"$RVTC_NAME\")).name = \"$RVTC_NEW_NAME\" |\
344350
(.packages[0].tools[] | select(.name==\"$RVTC_NAME\")).version = \"$RVTC_VERSION\" |\
345-
(.packages[0].tools[] | select(.name==\"$RVTC_NAME\")).name = \"$RVTC_NEW_NAME\""
351+
(.packages[0].tools[] | select(.name==\"$RVTC_NAME\")).name = \"$RVTC_NEW_NAME\" |\
352+
(.packages[0].platforms[0].toolsDependencies[] | select(.name==\"$X32TC_NAME\")).version = \"$RVTC_VERSION\" |\
353+
(.packages[0].platforms[0].toolsDependencies[] | select(.name==\"$X32TC_NAME\")).name = \"$X32TC_NEW_NAME\" |\
354+
(.packages[0].tools[] | select(.name==\"$X32TC_NAME\")).version = \"$RVTC_VERSION\" |\
355+
(.packages[0].tools[] | select(.name==\"$X32TC_NAME\")).name = \"$X32TC_NEW_NAME\" |\
356+
(.packages[0].platforms[0].toolsDependencies[] | select(.name==\"$XS2TC_NAME\")).version = \"$RVTC_VERSION\" |\
357+
(.packages[0].platforms[0].toolsDependencies[] | select(.name==\"$XS2TC_NAME\")).name = \"$XS2TC_NEW_NAME\" |\
358+
(.packages[0].tools[] | select(.name==\"$XS2TC_NAME\")).version = \"$RVTC_VERSION\" |\
359+
(.packages[0].tools[] | select(.name==\"$XS2TC_NAME\")).name = \"$XS2TC_NEW_NAME\" |\
360+
(.packages[0].platforms[0].toolsDependencies[] | select(.name==\"$XS3TC_NAME\")).version = \"$RVTC_VERSION\" |\
361+
(.packages[0].platforms[0].toolsDependencies[] | select(.name==\"$XS3TC_NAME\")).name = \"$XS3TC_NEW_NAME\" |\
362+
(.packages[0].tools[] | select(.name==\"$XS3TC_NAME\")).version = \"$RVTC_VERSION\" |\
363+
(.packages[0].tools[] | select(.name==\"$XS3TC_NAME\")).name = \"$XS3TC_NEW_NAME\""
346364
cat "$PACKAGE_JSON_TEMPLATE" | jq "$rvtc_jq_arg" > "$OUTPUT_DIR/package-$LIBS_PROJ_NAME-rvfix.json"
347365
PACKAGE_JSON_TEMPLATE="$OUTPUT_DIR/package-$LIBS_PROJ_NAME-rvfix.json"
348366

Diff for: CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ set(includedirs variants/${CONFIG_ARDUINO_VARIANT}/ cores/esp32/ ${ARDUINO_LIBRA
288288
set(srcs ${CORE_SRCS} ${ARDUINO_LIBRARIES_SRCS})
289289
set(priv_includes cores/esp32/libb64)
290290
set(requires spi_flash esp_partition mbedtls wifi_provisioning wpa_supplicant esp_adc esp_eth http_parser)
291-
set(priv_requires fatfs nvs_flash app_update spiffs bootloader_support bt esp_hid usb ${ARDUINO_LIBRARIES_REQUIRES})
291+
set(priv_requires fatfs nvs_flash app_update spiffs bootloader_support bt esp_hid usb esp_psram ${ARDUINO_LIBRARIES_REQUIRES})
292292

293293
idf_component_register(INCLUDE_DIRS ${includedirs} PRIV_INCLUDE_DIRS ${priv_includes} SRCS ${srcs} REQUIRES ${requires} PRIV_REQUIRES ${priv_requires})
294294

Diff for: boards.txt

+24
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ esp32c2.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SP
8787
esp32c2.menu.PartitionScheme.default.build.partitions=default
8888
esp32c2.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FATFS)
8989
esp32c2.menu.PartitionScheme.defaultffat.build.partitions=default_ffat
90+
esp32c2.menu.PartitionScheme.no_fs=No FS 4MB (2MB APP x2)
91+
esp32c2.menu.PartitionScheme.no_fs.build.partitions=no_fs
92+
esp32c2.menu.PartitionScheme.no_fs.upload.maximum_size=2031616
9093
esp32c2.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
9194
esp32c2.menu.PartitionScheme.no_ota.build.partitions=no_ota
9295
esp32c2.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
@@ -223,6 +226,9 @@ esp32h2.menu.PartitionScheme.default_8MB.build.partitions=default_8MB
223226
esp32h2.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336
224227
esp32h2.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
225228
esp32h2.menu.PartitionScheme.minimal.build.partitions=minimal
229+
esp32h2.menu.PartitionScheme.no_fs=No FS 4MB (2MB APP x2)
230+
esp32h2.menu.PartitionScheme.no_fs.build.partitions=no_fs
231+
esp32h2.menu.PartitionScheme.no_fs.upload.maximum_size=2031616
226232
esp32h2.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
227233
esp32h2.menu.PartitionScheme.no_ota.build.partitions=no_ota
228234
esp32h2.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
@@ -400,6 +406,9 @@ esp32c6.menu.PartitionScheme.default_8MB.build.partitions=default_8MB
400406
esp32c6.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336
401407
esp32c6.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
402408
esp32c6.menu.PartitionScheme.minimal.build.partitions=minimal
409+
esp32c6.menu.PartitionScheme.no_fs=No FS 4MB (2MB APP x2)
410+
esp32c6.menu.PartitionScheme.no_fs.build.partitions=no_fs
411+
esp32c6.menu.PartitionScheme.no_fs.upload.maximum_size=2031616
403412
esp32c6.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
404413
esp32c6.menu.PartitionScheme.no_ota.build.partitions=no_ota
405414
esp32c6.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
@@ -666,6 +675,9 @@ esp32s3.menu.PartitionScheme.default_8MB.build.partitions=default_8MB
666675
esp32s3.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336
667676
esp32s3.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
668677
esp32s3.menu.PartitionScheme.minimal.build.partitions=minimal
678+
esp32s3.menu.PartitionScheme.no_fs=No FS 4MB (2MB APP x2)
679+
esp32s3.menu.PartitionScheme.no_fs.build.partitions=no_fs
680+
esp32s3.menu.PartitionScheme.no_fs.upload.maximum_size=2031616
669681
esp32s3.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
670682
esp32s3.menu.PartitionScheme.no_ota.build.partitions=no_ota
671683
esp32s3.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
@@ -828,6 +840,9 @@ esp32c3.menu.PartitionScheme.default_8MB.build.partitions=default_8MB
828840
esp32c3.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336
829841
esp32c3.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
830842
esp32c3.menu.PartitionScheme.minimal.build.partitions=minimal
843+
esp32c3.menu.PartitionScheme.no_fs=No FS 4MB (2MB APP x2)
844+
esp32c3.menu.PartitionScheme.no_fs.build.partitions=no_fs
845+
esp32c3.menu.PartitionScheme.no_fs.upload.maximum_size=2031616
831846
esp32c3.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
832847
esp32c3.menu.PartitionScheme.no_ota.build.partitions=no_ota
833848
esp32c3.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
@@ -1026,6 +1041,9 @@ esp32s2.menu.PartitionScheme.default_8MB.build.partitions=default_8MB
10261041
esp32s2.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336
10271042
esp32s2.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
10281043
esp32s2.menu.PartitionScheme.minimal.build.partitions=minimal
1044+
esp32s2.menu.PartitionScheme.no_fs=No FS 4MB (2MB APP x2)
1045+
esp32s2.menu.PartitionScheme.no_fs.build.partitions=no_fs
1046+
esp32s2.menu.PartitionScheme.no_fs.upload.maximum_size=2031616
10291047
esp32s2.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
10301048
esp32s2.menu.PartitionScheme.no_ota.build.partitions=no_ota
10311049
esp32s2.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
@@ -1199,6 +1217,9 @@ esp32.menu.PartitionScheme.default_8MB.build.partitions=default_8MB
11991217
esp32.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336
12001218
esp32.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
12011219
esp32.menu.PartitionScheme.minimal.build.partitions=minimal
1220+
esp32.menu.PartitionScheme.no_fs=No FS 4MB (2MB APP x2)
1221+
esp32.menu.PartitionScheme.no_fs.build.partitions=no_fs
1222+
esp32.menu.PartitionScheme.no_fs.upload.maximum_size=2031616
12021223
esp32.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
12031224
esp32.menu.PartitionScheme.no_ota.build.partitions=no_ota
12041225
esp32.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
@@ -1369,6 +1390,9 @@ esp32da.menu.PartitionScheme.default_8MB.build.partitions=default_8MB
13691390
esp32da.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336
13701391
esp32da.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
13711392
esp32da.menu.PartitionScheme.minimal.build.partitions=minimal
1393+
esp32da.menu.PartitionScheme.no_fs=No FS 4MB (2MB APP x2)
1394+
esp32da.menu.PartitionScheme.no_fs.build.partitions=no_fs
1395+
esp32da.menu.PartitionScheme.no_fs.upload.maximum_size=2031616
13721396
esp32da.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
13731397
esp32da.menu.PartitionScheme.no_ota.build.partitions=no_ota
13741398
esp32da.menu.PartitionScheme.no_ota.upload.maximum_size=2097152

Diff for: cores/esp32/esp32-hal-tinyusb.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#elif CONFIG_IDF_TARGET_ESP32S3
4444
#if defined __has_include && __has_include("hal/usb_phy_ll.h")
4545
#include "hal/usb_phy_ll.h"
46-
#else
46+
#elif defined __has_include && __has_include("hal/usb_fsls_phy_ll.h")
4747
#include "hal/usb_fsls_phy_ll.h"
4848
#endif
4949
#include "hal/usb_serial_jtag_ll.h"
@@ -503,8 +503,13 @@ static void usb_switch_to_cdc_jtag() {
503503
// Initialize CDC+JTAG ISR to listen for BUS_RESET
504504
#if defined __has_include && __has_include("hal/usb_phy_ll.h")
505505
usb_phy_ll_int_jtag_enable(&USB_SERIAL_JTAG);
506-
#else
506+
#elif defined __has_include && __has_include("hal/usb_fsls_phy_ll.h")
507507
usb_fsls_phy_ll_int_jtag_enable(&USB_SERIAL_JTAG);
508+
#else
509+
// usb_serial_jtag_ll_phy_set_defaults();
510+
const usb_serial_jtag_pull_override_vals_t pull_conf = {.dp_pu = 1, .dm_pu = 0, .dp_pd = 0, .dm_pd = 0};
511+
usb_serial_jtag_ll_phy_enable_pull_override(&pull_conf);
512+
usb_serial_jtag_ll_phy_disable_pull_override();
508513
#endif
509514
usb_serial_jtag_ll_disable_intr_mask(USB_SERIAL_JTAG_LL_INTR_MASK);
510515
usb_serial_jtag_ll_clr_intsts_mask(USB_SERIAL_JTAG_LL_INTR_MASK);

Diff for: docs/en/esp-idf_component.rst

+7-9
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@
22
Arduino as an ESP-IDF component
33
###############################
44

5-
This method is recommended for advanced users. To use this method, you will need to have the ESP-IDF toolchain installed.
6-
7-
For a simplified method, see `Installing using Boards Manager <https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html#installing-using-boards-manager>`_.
5+
About
6+
-----
87

9-
ESP32 Arduino lib-builder
10-
-------------------------
8+
You can use the Arduino framework as an ESP-IDF component. This allows you to use the Arduino framework in your ESP-IDF projects with the full flexibility of the ESP-IDF.
119

12-
If you don't need any modifications in the default Arduino ESP32 core, we recommend you to install using the Boards Manager.
13-
14-
Arduino Lib Builder is the tool that integrates ESP-IDF into Arduino. It allows you to customize the default settings used by Espressif and try them in Arduino IDE.
10+
This method is recommended for advanced users. To use this method, you will need to have the ESP-IDF toolchain installed.
1511

16-
For more information see `Arduino lib builder <https://github.com/espressif/esp32-arduino-lib-builder>`_
12+
For a simplified method, see `Installing using Boards Manager <https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html#installing-using-boards-manager>`_.
1713

14+
If you plan to use these modified settings multiple times, for different projects and targets, you can recompile the Arduino core with the new settings using the Arduino Static Library Builder.
15+
For more information, see the `Lib Builder documentation <lib_builder.html>`_.
1816

1917
Installation
2018
------------

Diff for: idf_component.yml

+10-6
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ files:
4444
dependencies:
4545
idf: ">=5.1,<5.2"
4646
# mdns 1.2.1 is necessary to build H2 with no WiFi
47-
mdns: "^1.2.3"
48-
espressif/esp_modem: "^1.1.0"
49-
chmorgan/esp-libhelix-mp3:
50-
version: "1.0.3"
47+
espressif/mdns:
48+
version: "^1.2.3"
5149
require: public
50+
espressif/esp_modem:
51+
version: "^1.1.0"
5252
espressif/esp-zboss-lib:
5353
version: "^1.0.1"
5454
rules:
@@ -57,7 +57,7 @@ dependencies:
5757
version: "^1.0.1"
5858
rules:
5959
- if: "target != esp32c2"
60-
esp-dsp:
60+
espressif/esp-dsp:
6161
version: "^1.3.4"
6262
rules:
6363
- if: "target != esp32c2"
@@ -77,10 +77,14 @@ dependencies:
7777
version: "^0.1.0~1"
7878
rules:
7979
- if: "target != esp32c2"
80-
joltwallet/littlefs: "^1.10.2"
8180
espressif/esp-sr:
8281
version: "^1.4.2"
8382
rules:
8483
- if: "target in [esp32s3]"
84+
joltwallet/littlefs:
85+
version: "^1.10.2"
86+
chmorgan/esp-libhelix-mp3:
87+
version: "1.0.3"
88+
require: public
8589
examples:
8690
- path: ./idf_component_examples/Hello_world

Diff for: libraries/NetworkClientSecure/src/NetworkClientSecure.cpp

+37-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ NetworkClientSecure::NetworkClientSecure() {
4040
sslclient->socket = -1;
4141
sslclient->handshake_timeout = 120000;
4242
_use_insecure = false;
43+
_stillinPlainStart = false;
44+
_ca_cert_free = false;
45+
_cert_free = false;
46+
_private_key_free = false;
4347
_CA_cert = NULL;
4448
_cert = NULL;
4549
_private_key = NULL;
@@ -68,6 +72,11 @@ NetworkClientSecure::NetworkClientSecure(int sock) {
6872
_connected = true;
6973
}
7074

75+
_use_insecure = false;
76+
_stillinPlainStart = false;
77+
_ca_cert_free = false;
78+
_cert_free = false;
79+
_private_key_free = false;
7180
_CA_cert = NULL;
7281
_cert = NULL;
7382
_private_key = NULL;
@@ -77,7 +86,17 @@ NetworkClientSecure::NetworkClientSecure(int sock) {
7786
_alpn_protos = NULL;
7887
}
7988

80-
NetworkClientSecure::~NetworkClientSecure() {}
89+
NetworkClientSecure::~NetworkClientSecure() {
90+
if (_ca_cert_free && _CA_cert) {
91+
free((void *)_CA_cert);
92+
}
93+
if (_cert_free && _cert) {
94+
free((void *)_cert);
95+
}
96+
if (_private_key_free && _private_key) {
97+
free((void *)_private_key);
98+
}
99+
}
81100

82101
void NetworkClientSecure::stop() {
83102
stop_ssl_socket(sslclient.get());
@@ -310,25 +329,39 @@ void NetworkClientSecure::setInsecure() {
310329
}
311330

312331
void NetworkClientSecure::setCACert(const char *rootCA) {
332+
if (_ca_cert_free && _CA_cert) {
333+
free((void *)_CA_cert);
334+
_ca_cert_free = false;
335+
}
313336
_CA_cert = rootCA;
314337
_use_insecure = false;
315338
}
316339

317340
void NetworkClientSecure::setCACertBundle(const uint8_t *bundle) {
318341
if (bundle != NULL) {
319342
esp_crt_bundle_set(bundle, sizeof(bundle));
343+
attach_ssl_certificate_bundle(sslclient.get(), true);
320344
_use_ca_bundle = true;
321345
} else {
322346
esp_crt_bundle_detach(NULL);
347+
attach_ssl_certificate_bundle(sslclient.get(), false);
323348
_use_ca_bundle = false;
324349
}
325350
}
326351

327352
void NetworkClientSecure::setCertificate(const char *client_ca) {
353+
if (_cert_free && _cert) {
354+
free((void *)_cert);
355+
_cert_free = false;
356+
}
328357
_cert = client_ca;
329358
}
330359

331360
void NetworkClientSecure::setPrivateKey(const char *private_key) {
361+
if (_private_key_free && _private_key) {
362+
free((void *)_private_key);
363+
_private_key_free = false;
364+
}
332365
_private_key = private_key;
333366
}
334367

@@ -367,6 +400,7 @@ bool NetworkClientSecure::loadCACert(Stream &stream, size_t size) {
367400
bool ret = false;
368401
if (dest) {
369402
setCACert(dest);
403+
_ca_cert_free = true;
370404
ret = true;
371405
}
372406
return ret;
@@ -380,6 +414,7 @@ bool NetworkClientSecure::loadCertificate(Stream &stream, size_t size) {
380414
bool ret = false;
381415
if (dest) {
382416
setCertificate(dest);
417+
_cert_free = true;
383418
ret = true;
384419
}
385420
return ret;
@@ -393,6 +428,7 @@ bool NetworkClientSecure::loadPrivateKey(Stream &stream, size_t size) {
393428
bool ret = false;
394429
if (dest) {
395430
setPrivateKey(dest);
431+
_private_key_free = true;
396432
ret = true;
397433
}
398434
return ret;

Diff for: libraries/NetworkClientSecure/src/NetworkClientSecure.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ class NetworkClientSecure : public NetworkClient {
3131
std::shared_ptr<sslclient_context> sslclient;
3232

3333
bool _use_insecure;
34-
bool _stillinPlainStart = false;
34+
bool _stillinPlainStart;
35+
bool _ca_cert_free;
36+
bool _cert_free;
37+
bool _private_key_free;
3538
const char *_CA_cert;
3639
const char *_cert;
3740
const char *_private_key;

Diff for: libraries/NetworkClientSecure/src/ssl_client.cpp

+16-5
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ void ssl_init(sslclient_context *ssl_client) {
5151
ssl_client->peek_buf = -1;
5252
}
5353

54+
void attach_ssl_certificate_bundle(sslclient_context *ssl_client, bool att) {
55+
if (att) {
56+
ssl_client->bundle_attach_cb = &esp_crt_bundle_attach;
57+
} else {
58+
ssl_client->bundle_attach_cb = NULL;
59+
}
60+
}
61+
5462
int start_ssl_client(
5563
sslclient_context *ssl_client, const IPAddress &ip, uint32_t port, const char *hostname, int timeout, const char *rootCABuff, bool useRootCABundle,
5664
const char *cli_cert, const char *cli_key, const char *pskIdent, const char *psKey, bool insecure, const char **alpn_protos
@@ -195,11 +203,14 @@ int start_ssl_client(
195203
return handle_error(ret);
196204
}
197205
} else if (useRootCABundle) {
198-
log_v("Attaching root CA cert bundle");
199-
ret = esp_crt_bundle_attach(&ssl_client->ssl_conf);
200-
201-
if (ret < 0) {
202-
return handle_error(ret);
206+
if (ssl_client->bundle_attach_cb != NULL) {
207+
log_v("Attaching root CA cert bundle");
208+
ret = ssl_client->bundle_attach_cb(&ssl_client->ssl_conf);
209+
if (ret < 0) {
210+
return handle_error(ret);
211+
}
212+
} else {
213+
log_e("useRootCABundle is set, but attach_ssl_certificate_bundle(ssl, true); was not called!");
203214
}
204215
} else if (pskIdent != NULL && psKey != NULL) {
205216
log_v("Setting up PSK");

0 commit comments

Comments
 (0)