WiFI/Ethernet client with DTLS

This is a DTLS client sample in C that uses the mbedtls library. This is a library used in both Zephy, ESP-IDF and other projects.

The source code is available int the GitHub repo https://github.com/lab5e/dtls-mbedtls-sample A detailed description of the sample is available in this blog post.

Client certificate and private key

The sample code reads the certificate and private key from the files cert.crt and key.pem. Both files must be PEM-encoded. The cert.crt contains the client certificate, intermediates and root and the key.pem file contains the private key.

Use the span CLI to generate a certificate and key file.

Building on Raspberry Pi

This example buidls on Raspberr Pi (including Zero) - run

sudo apt-get install libmbedtls-dev

to install the mbedtls headers, then


to build to example.

Building on Fedora-based


sudo dnf install mbedtls mbedtls-devel make gcc