Skip to content

Add Mbed TLS 4.x support#2499

Closed
daveisfera wants to merge 4 commits into
yhirose:masterfrom
daveisfera:mbedtls-4-support
Closed

Add Mbed TLS 4.x support#2499
daveisfera wants to merge 4 commits into
yhirose:masterfrom
daveisfera:mbedtls-4-support

Conversation

@daveisfera

Copy link
Copy Markdown

Summary

  • Extend the Mbed TLS backend to auto-detect 4.x (CPPHTTPLIB_MBEDTLS_V4): PSA Crypto init, drop CTR-DRBG/mbedtls_ssl_conf_rng, use PSA hashes, and link libtfpsacrypto when present.
  • Treat TLS 1.3 MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET as non-fatal so online HTTPS works on 4.x.
  • Update CMake/meson/Makefile/docs and add mbedtls4 CI coverage on Ubuntu (build from release tarball), macOS (Homebrew), and proxy tests.

Test plan

  • Local smoke + SSL gtests against Homebrew Mbed TLS 4.2 and 3.6
  • Online HTTPS (Google/example.com) with system CA verify on 4.x
  • CI: ubuntu (mbedtls4), macos (mbedtls4), proxy (mbedtls4)
  • CI: existing mbedtls (3.x) jobs still green

Made with Cursor

daveisfera and others added 4 commits July 17, 2026 16:05
Auto-detect Mbed TLS 4.x and adapt the TLS backend for PSA init, removed
CTR-DRBG/RNG callbacks, tfpsacrypto linking, and TLS 1.3 session-ticket
retries so 2.x/3.x/4.x all work through CPPHTTPLIB_MBEDTLS_SUPPORT.

Co-authored-by: Cursor <cursoragent@cursor.com>
Mbed TLS 4 rejects PBE-SHA1-3DES encrypted client keys used by gen-certs,
so generate PBES2 AES-wrapped keys instead. Also satisfy clang-format 18.

Co-authored-by: Cursor <cursoragent@cursor.com>
Ubuntu's Mbed TLS 2.28 can only decrypt DES/PBES1 keys, while 4.x rejects
DES. Generate both wraps from one keypair and select by Mbed TLS version.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@daveisfera

Copy link
Copy Markdown
Author

Looks like you made your own version of this with #2502 so close this if you'd like

@yhirose

yhirose commented Jul 21, 2026

Copy link
Copy Markdown
Owner

@daveisfera, thanks for the pull request!

The reason httplib didn’t support MbedTLS 4.x is that package managers like apt and Homebrew didn’t provide 4.x packages yet. However, Homebrew has now started using 4.x as the default instead of 3.5, so I can use it without building from source.

I’ve just tried implementing 4.x support in my version with as few changes as possible.

@yhirose yhirose closed this Jul 21, 2026
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.

2 participants