From 530174f31ebd86527f941108619bb3f9d1d281c0 Mon Sep 17 00:00:00 2001 From: David Montero Crespo Date: Thu, 14 May 2026 12:38:20 -0300 Subject: [PATCH] fix(espidf): enable mbedTLS PSK so ssl_client.cpp links arduino-esp32 v2.0.17's libraries/WiFiClientSecure/src/ssl_client.cpp:23 wraps its entire body in: #if !defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) \ && !defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED) # warning "Please call idf.py menuconfig ..." #else ssl_init / start_ssl_client / stop_ssl_socket / send_ssl_data / get_ssl_receive / data_to_read #endif Our esp-idf-template/sdkconfig.defaults did not enable any PSK key-exchange mode, so MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED was never auto-set by mbedtls and ssl_client.cpp compiled to an empty translation unit. The companion WiFiClientSecure.cpp still compiled and ended up in libarduino-esp32.a with dangling references, breaking the link of every sketch that pulls in HTTPClient or WiFiClientSecure (directly or transitively). Reproduced against the user's WiFi + HTTPClient example.com sketch on the prod server and again locally with ESP-IDF v4.4.7 + arduino-esp32 v2.0.17; the prebuilt sdkconfig that ships with arduino-esp32 itself sets both flags, so we just align with that. After the fix the same sketch links cleanly: velxio-sketch.bin binary size 0xbf470 bytes ... 25% free Co-Authored-By: Claude Opus 4.7 (1M context) --- backend/app/services/esp-idf-template/sdkconfig.defaults | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/backend/app/services/esp-idf-template/sdkconfig.defaults b/backend/app/services/esp-idf-template/sdkconfig.defaults index 9cc662ae..e04b8b2d 100644 --- a/backend/app/services/esp-idf-template/sdkconfig.defaults +++ b/backend/app/services/esp-idf-template/sdkconfig.defaults @@ -25,6 +25,15 @@ CONFIG_COMPILER_OPTIMIZATION_SIZE=y # WiFi CONFIG_ESP_WIFI_ENABLED=y +# mbedTLS — PSK ciphersuites must be enabled or arduino-esp32 v2.0.17's +# ssl_client.cpp compiles to an empty translation unit (its body is wrapped +# in `#if !defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED) ... #else ... #endif`). +# Without these, any sketch that pulls in HTTPClient or WiFiClientSecure +# fails to link with undefined references to ssl_init / start_ssl_client / +# stop_ssl_socket / send_ssl_data / get_ssl_receive / data_to_read. +CONFIG_MBEDTLS_PSK_MODES=y +CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y + # LWIP — reassembly needed for slirp networking CONFIG_LWIP_IP4_REASSEMBLY=y CONFIG_LWIP_IP6_REASSEMBLY=y