Skip to content

feat(tls): add mbedTLS backend for DoT and DNSSEC#552

Open
Oppen wants to merge 1 commit into
getdnsapi:developfrom
Oppen:mbedtls-backend
Open

feat(tls): add mbedTLS backend for DoT and DNSSEC#552
Oppen wants to merge 1 commit into
getdnsapi:developfrom
Oppen:mbedtls-backend

Conversation

@Oppen

@Oppen Oppen commented Jul 10, 2026

Copy link
Copy Markdown

Adds src/mbedtls/ implementing the tls.h transport interface against
mbedTLS 3.x/4.x's PSA API, and a new HAVE_MBEDTLS branch in
src/tls/val_secalgo.c so DNSSEC verification no longer pulls in
OpenSSL or Nettle when USE_MBEDTLS is selected.

DNSSEC support covers RSA and ECDSA only: mbedTLS has no DSA or GOST
implementation, and no EdDSA (Ed25519/Ed448) implementation despite
declaring PSA_ALG_PURE_EDDSA and the twisted-Edwards curve family in
its public headers.

SPKI pinning is checked by hand post-handshake (mbedTLS has no
DANE-alike API), and session-resumption status always reports fresh
since mbedTLS 4.x has no public API to query it.

On dynamic linking builds, user is responsible for matching versions
correctly.

Tested on MacOS by running the regression tests with the following matrix:
(mbedtls 3.6, mbedtls 4.2)x(static link, dynamic link)x(runtime version, no runtime version)

Tested on OpenWRT 25.12.4 with dynamic link 3.6.6, no runtime version
(default deploy, no new mbedtls build), running manual queries with
getdns_query and by setting up stubby as forward for dnsmasq
(which is my actual use case, my router can't fit OpenSSL and I wanted
to use uBlockDNS, which requires DoT or DoH).

DISCLAIMER: this is mostly vibe-coded, I tested and reviewed the code
an am responsible for it and guided the development through the hallucinations,
but it was machine generated. I couldn't find any policy about LLM
generated code, but I understand if it is considered in bad taste.

Fixes #454
Sorta fixes getdnsapi/stubby#311

Adds src/mbedtls/ implementing the tls.h transport interface against
mbedTLS 3.x/4.x's PSA API, and a new HAVE_MBEDTLS branch in
src/tls/val_secalgo.c so DNSSEC verification no longer pulls in
OpenSSL or Nettle when USE_MBEDTLS is selected.

DNSSEC support covers RSA and ECDSA only: mbedTLS has no DSA or GOST
implementation, and no EdDSA (Ed25519/Ed448) implementation despite
declaring PSA_ALG_PURE_EDDSA and the twisted-Edwards curve family in
its public headers.

SPKI pinning is checked by hand post-handshake (mbedTLS has no
DANE-alike API), and session-resumption status always reports fresh
since mbedTLS 4.x has no public API to query it.

On dynamic linking builds, user is responsible for matching versions
correctly.
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.

WolfSSL Compatibility Is there any plan to migrate to wolfssl or mbedtls?

1 participant