Now in Beta: A Drop-In Replacement for Mbed TLS 4.x, Built on wolfSSL

Earlier this month we announced an Mbed TLS 4.x compatibility layer in wolfPSA. That layer is now in beta. TLS 1.2 and TLS 1.3 clients and servers work today, with X.509 certificates and Mbed TLS’s basic socket functions. An application written for Mbed TLS 4.x builds without source changes and links libwolfpsa.a in place of libmbedtls, libmbedx509 and libtfpsacrypto.

The Mbed TLS maintainers will stop working on the TLS and X.509 libraries in April 2027 and we previously covered what that means for your product, so now is a good time to try your application on wolfSSL.

Get Started

The beta builds from the master branches of wolfPSA and wolfSSL. Clone both side by side, then build wolfPSA with the Mbed TLS layer:

git clone https://github.com/wolfSSL/wolfssl
git clone https://github.com/wolfSSL/wolfPSA
cd wolfPSA
make MBEDTLS_COMPAT=1

This compiles wolfCrypt and wolfSSL’s TLS code from ../wolfssl into libwolfpsa.a, so you do not need to install wolfSSL.

Run the Example Client

The mbedtls-compat example in wolfssl-examples is the Mbed TLS client from the “Porting a TLS Client” chapter of our migration guide, built on wolfPSA. From the directory that has your wolfssl and wolfPSA clones, build it and connect to a public HTTPS server, giving the port and your system’s CA bundle:

git clone https://github.com/wolfSSL/wolfssl-examples
cd wolfssl-examples/mbedtls-compat
make
./client-tls-mbedtls -p 443 -A /etc/ssl/certs/ca-certificates.crt www.wolfssl.com

The client prints the TLS version and cipher suite it used:

Handshake done, TLSv1.3, TLS1-3-AES-128-GCM-SHA256
tls_get() returned 0

Other servers, such as google.com and letsencrypt.org, work the same way. When a certificate does not verify, the client prints why, as Mbed TLS’s sample programs do. Its README shows how to run it against a wolfSSL server.

Run Mbed TLS’s Client and Server

To see Mbed TLS’s own programs run on wolfSSL, have wolfPSA fetch Mbed TLS 4.2.0 and build its sample programs, unchanged. From the wolfPSA directory:

make MBEDTLS_COMPAT=1 mbedtls-compat-programs

This needs network access, Python 3 and autotools. It runs the programs against the wolfSSL example client and server, then leaves them in build/mbedtls_compat/programs for you to try. Start Mbed TLS’s ssl_server:

cd build/mbedtls_compat/programs/ssl
./ssl_server

Then, from the same directory in a second terminal, connect with Mbed TLS’s ssl_client1, or with curl:

./ssl_client1
curl -k https://localhost:4433/

The server replies with the TLS version and cipher suite it used, such as Successful connection using: TLS1-3-AES-256-GCM-SHA384.

Build Your Application

Build your application against wolfPSA’s headers and library, in place of Mbed TLS’s, as the example client’s Makefile does:

WOLFPSA=/path/to/wolfPSA
cc -I$WOLFPSA/wolfpsa -I$WOLFPSA/wolfpsa/mbedtls_compat -I$WOLFPSA/build/include \
    my_app.c $WOLFPSA/libwolfpsa.a -lm -o my_app

The headers have Mbed TLS’s names, structs, return codes and feature macros, and include no wolfSSL header, so your code does not change. For a thread-safe build, add MBEDTLS_THREADING_C=1 to the make line, define MBEDTLS_THREADING_C in your application as you would with Mbed TLS, and link with -pthread.

The compatibility guide lists every supported function, the build options and what the tests need.

What Works in the Beta

  • TLS 1.2 and TLS 1.3, client and server, over mbedtls_net_* sockets or your own I/O callbacks through mbedtls_ssl_set_bio()
  • Certificate verification with host name checks, verify callbacks and MBEDTLS_SSL_VERIFY_OPTIONAL
  • As in Mbed TLS, a chain is trusted once it reaches a CA from your CA list, even when the server also sends a cross-signed root above that CA, as google.com does
  • RSA keys up to 4096 bits, so chains through an RSA-4096 CA, such as Let’s Encrypt’s ISRG Root X1, verify
  • Session resumption, including mbedtls_ssl_session_save() and mbedtls_ssl_session_load()
  • Key export (mbedtls_ssl_export_keying_material()), max fragment length and the timing API
  • X.509 certificate parsing from memory, files and directories, in PEM or DER, and certificate info text with mbedtls_x509_crt_info()
  • mbedtls_strerror() and PEM parsing
  • From TF-PSA-Crypto: mbedtls/pk.h key parsing, mbedtls/md.h hashing and mbedtls/base64.h
  • The PSA Certified Crypto API 1.4 with the PQC extension, on wolfCrypt
  • Thread-safe TLS with MBEDTLS_THREADING_C

Known differences from Mbed TLS behavior are listed in the compatibility guide, so you know up front what to check in your port.

Tested Against Mbed TLS’s Own Code

Every change to wolfPSA runs in CI against Mbed TLS 4.2.0, in a default build and in a thread-safe build under AddressSanitizer:

  • Mbed TLS’s sample programs, built unchanged, run against the wolfSSL example client and server
  • The cases of Mbed TLS’s TLS unit tests that use the public API run against the layer
  • The same cases also run on Mbed TLS’s own libraries, which shows the ported tests still test what Mbed TLS’s tests do

To run the first two on your machine, along with wolfPSA’s own tests of the layer, use make MBEDTLS_COMPAT=1 mbedtls-compat-test.

Feature-Complete Mbed TLS 4.x by the End of 2026

Our goal is to complete the Mbed TLS 4.x TLS, DTLS and X.509 API by the end of the year. Coming next:

  • Session tickets, PSK and opaque keys
  • DTLS, including cookies, connection ID and context save and load. UDP sockets in mbedtls_net_* are already in place.
  • ALPN
  • Read timeouts and non-blocking sockets (mbedtls_ssl_conf_read_timeout(), mbedtls_net_set_nonblock())
  • CRLs, mbedtls_x509_crt_verify() and CSR parsing
  • The peer certificate, for certificate pinning
  • More of TF-PSA-Crypto, such as the rest of mbedtls/pk.h and mbedtls/asn1.h

The full list is in the compatibility guide. After that come drop-in build files (pkg-config, a CMake package, and Mbed TLS’s library names) and a Zephyr option for the layer.

What About Mbed TLS 3.6 LTS?

Mbed TLS 3.6 LTS reaches end of life in March 2027, and many shipping products still use it. Its API is larger than 4.x: besides TLS and X.509, 3.6 applications call the older crypto API directly (mbedtls_aes_*, mbedtls_rsa_*, mbedtls_ctr_drbg_* and more), which 4.x replaced with PSA. Compatibility support for the 3.x API is on our roadmap. If your product is on 3.6, tell us which parts of the API it uses, since that helps us prioritize. Need to move sooner? The Mbed TLS to wolfSSL Migration Guide walks you through a port to the native wolfSSL API.

Try It and Engage with Us

Try the beta with your Mbed TLS 4.x application and let us know what works and what does not, through an issue on wolfPSA or by email.

If you have questions about any of the above, please contact us at facts@wolfssl.com or call us at +1 425 245 8247.

Download wolfSSL Now