Improve PlatformIO Certificate Bundle Support #8847
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Draft - testing still in progress, not all examples updated with wolfSSL component files.
Description
This PR improves the build experience with wolfSSL when using PlatformIO for:
wolfSSL_Init()
time.user_settings.h
,Kconfig
,CMakeLists.txt
files.Note that the concept of a Certificate Bundles is non-standard, with no RCF, and has been implemented at wolfSSL only for Espressif SDK compatibility and consistency. This is to allow customers to easily migrate to wolfSSL. See wolfSSL Manual: Keys and Certificates for the recommended usage.
Getting Started with wolfSSL on PlatformIO
See blog: https://www.wolfssl.com/wolfssl-now-supported-on-platformio/
Background
PlatformIO works slightly differently with ESP-IDF CMake as compared to using the
idf.py build
.One key difference is regarding the silent failure to call scripts at build time, for example the
gen_crt_bundle.py
for either the Espressif SDK mbedtls component or for the wolfSSL component.Reminder: the resulting file from
gen_crt_bundle.py
when called for the mbedTLS component file is NOT binary compatible with the file generated by the wolfssl component.Additionally, all environments using CMake have an issue where once built the first time, many CMake files remain cached and some messages are not regenerated, not visible on subsequent builds.
See also
Core wolfSSL
Introduction of
HAVE_LIBWOLFSSL_OUTPUT_HEADER
. This macro is defined when multiple calls are make to the new CMake functionAPPEND_LIBWOLFSSL_CMAKE_OUTPUT("message")
.Normally, prior versions of the LIBWOLFSSL_SAVE_INFO saved simple values to compile definitions, for example git attributes.
In this update there's an optional build-time-generated
libwolfssl_output.h
that contains properly formatted multi-line messages. Sample contents:When
HAVE_LIBWOLFSSL_OUTPUT_HEADER
is defined, theesp32_util.c
will now#include "libwolfssl_output.h"
.The Espressif ShowExtendedSystemInfo has been modified to also show the contents of
LIBWOLFSSL_CMAKE_OUTPUT
.This addition to
wolfSSL_Init(void)
at initialization time prints the CMake messages when available:Certificate Bundles
The respective wolfssl component
CMakeLists.txt
has been modified to use an explicit bundle file, instead of generating at build time.There are new options in the wolfSSL
Kconfig
used by theidp.py menuconfig
to enable alternate certificate bundle locations. This is particularly helpful for PlatformIO that does not generate a bundle. Others may also appreciate the flexibility to have a fixed bundle, possibly custom, and optionally outside of the normal build and source directories.See new options:
CONFIG_WOLFSSL_ALTERNATE_CERTIFICATE_BUNDLE
to enable alternate locationWOLFSSL_ALTERNATE_CERTIFICATE_BUNDLE_PATH_AND_NAME
to provide relative or fully qualified file name and pathA new macro is introduced explicitly to provide more informative debug messages:
SHOW_WOLFSSL_BUNDLE_ERROR(err)
. This is available only whenCONFIG_WOLFSSL_DEBUG_CERT_BUNDLE
is enabled.There's a new option
NO_WOLFSSL_USE_ASM_CERT
to use a custom_binary_x509_crt_bundle_wolfssl_start
instead of the default asm file:Some environments outside of the ESP-IDF may need to have the Python
cryptography
installed, so thepio_install_cryptography.py
is also included here.Other Changes
Introduction of
CONFIG_ESP_WOLFSSL_NO_STACK_SIZE_BUILD_WARNING
. This allows disabling of the RSA minimum memory warning at compile time. This is useful when wolfSSL is running in a task other thanmain
.Minor cleanup, spelling corrections.
Fixes zd# 20015
Testing
How did you test?
Manual testing with customer, automated testing with my Espressif jig.
Tested with:
Commit: 848b80aeb52026648a8ff9f7c45a9b0a80641e2e
Date: 2025-05-14T21:47:40.416Z
Electron: 34.5.1
ElectronBuildId: 11369351
Chromium: 132.0.6834.210
Node.js: 20.19.0
V8: 13.2.152.41-electron.0
OS: Windows_NT x64 10.0.26100
Also tested with:
Version 17.12.5
VisualStudio.17.Release/17.12.5+35728.132
VisualGDB 6.0R8 (build 5338)
See also my fork of ESP-IDF with improved eps-tls support for wolfssl
For
platformio.ini
this is:For PlatformIO from command-line Windows/DOS:
Checklist