Skip to content

feat(esp-wolfssl): add wolfSSL certificate bundle support#31

Open
hrushikesh430 wants to merge 1 commit into
espressif:masterfrom
hrushikesh430:migrate/esp-idf-pr-16145
Open

feat(esp-wolfssl): add wolfSSL certificate bundle support#31
hrushikesh430 wants to merge 1 commit into
espressif:masterfrom
hrushikesh430:migrate/esp-idf-pr-16145

Conversation

@hrushikesh430

@hrushikesh430 hrushikesh430 commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

What the original esp-idf PRs did

The wolfSSL cert-bundle series in ESP-IDF added the wolfSSL equivalent of the mbedTLS certificate bundle:

  • #16145 — umbrella "Improve support for wolfssl" (the cert-bundle feature across esp-tls).
  • #17683 — esp-tls Kconfig + CMakeLists for the wolfSSL bundle.

They targeted the old built-in wolfSSL backend (CONFIG_ESP_TLS_USING_WOLFSSL), which no longer exists in ESP-IDF (wolfSSL now lives here as the esp-tls custom stack).

What this PR does

Re-implements the feature for the custom-stack model:

  • KconfigWOLFSSL_CERTIFICATE_BUNDLE (+ default FULL/NONE, max-certs, debug). Mutually exclusive with MBEDTLS_CERTIFICATE_BUNDLE (wolfSSL forbids both at once).
  • CMakeLists — compiles the wolfSSL esp_crt_bundle.c port and generates + embeds the CA blob (gen_crt_bundle.py_binary_x509_crt_bundle_wolfssl_*). That file is gated on the legacy CONFIG_ESP_TLS_USING_WOLFSSL and needs settings.h first, so both are forced for that single source.
  • esp_tls_wolfssl.c — wires crt_bundle_attach into the custom stack by handing our WOLFSSL_CTX to the bundle (installs a WOLFSSL_VERIFY_PEER callback). The ESP_ERR_NOT_SUPPORTED path stays when the feature is off.
  • user_settings.h — allows zero-serial CAs (WOLFSSL_ASN_ALLOW_0_SERIAL) when the bundle is enabled, so legacy roots are not dropped.

Usage (unchanged from mbedTLS): esp_tls_cfg_t cfg = { .crt_bundle_attach = esp_crt_bundle_attach };

Testing

  • ESP32-C5: a client using only the embedded bundle (no explicit CA) completes a TLS handshake to www.howsmyssl.com (PASS); after allowing zero-serial CAs the full bundle loads with no parse errors.
  • Default build (bundle disabled) still compiles cleanly — the feature is fully gated.

Migrated from esp-idf PRs #16145 and #17683 (wolfSSL cert-bundle series).

Adds the wolfSSL equivalent of CONFIG_MBEDTLS_CERTIFICATE_BUNDLE so apps can
verify TLS servers against an embedded common-root-CA bundle via
esp_tls_cfg_t.crt_bundle_attach = esp_crt_bundle_attach, without supplying a
CA certificate per connection.

- Kconfig: WOLFSSL_CERTIFICATE_BUNDLE (+ default FULL/NONE, MAX_CERTS, debug);
  mutually exclusive with MBEDTLS_CERTIFICATE_BUNDLE (wolfSSL forbids both).
- CMakeLists: compile the wolfSSL esp_crt_bundle.c port and generate + embed
  the CA bundle blob (gen_crt_bundle.py -> _binary_x509_crt_bundle_wolfssl_*).
  esp_crt_bundle.c is gated on the legacy CONFIG_ESP_TLS_USING_WOLFSSL and must
  include settings.h first, so both are forced for that single file.
- esp_tls_wolfssl.c: wire crt_bundle_attach into the custom stack by handing
  our WOLFSSL_CTX to the bundle (it installs a WOLFSSL_VERIFY_PEER callback);
  the ESP_ERR_NOT_SUPPORTED path remains when the feature is disabled.
- user_settings.h: allow zero-serial CAs (WOLFSSL_ASN_ALLOW_0_SERIAL) when the
  bundle is enabled so legacy roots are not dropped from the bundle.

Verified on ESP32-C5: a client using only the embedded bundle (no explicit CA)
completes a TLS handshake to www.howsmyssl.com.
@hrushikesh430 hrushikesh430 self-assigned this Jun 16, 2026
@hrushikesh430 hrushikesh430 marked this pull request as ready for review June 25, 2026 10:26
@hrushikesh430

Copy link
Copy Markdown
Collaborator Author

@mahavirj @AdityaHPatwardhan PTAL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant