]> git.ipfire.org Git - thirdparty/pdns.git/commit
dnsdist: Add support for switching certificates based on SNI w/ OpenSSL
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 4 Apr 2025 13:18:31 +0000 (15:18 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 14 Apr 2025 12:10:27 +0000 (14:10 +0200)
commit396bc0d448a04a982526d7d84bef7bf8ed9b73c8
treed5cf1473ff2208dec3aa519e871a78d0df10b4b8
parent9d7f2189b2ed85f1f8411cddc16a62797a1ebf13
dnsdist: Add support for switching certificates based on SNI w/ OpenSSL

We already supported this with GnuTLS, but OpenSSL does not make it
easy: we need to keep a different `SSL_CTX` object for each certificate/key
and change the `SSL_CTX` associated with an incoming connection to
the correct one based on the Server Name Indication from the servername
callback (actually OpenSSL devs advise to use the ClientHello callback
instead when using a recent enough version of OpenSSL, but the
SNI hostname is not available is not available at this point so we
would have to parse it ourselves, which is a terrible idea, and the
drawbacks are not clear. `nginx` has been getting away with it, so
hopefully we will as well).
One additional issue is that we still need to load certificates
for the same name but different key types (RSA vs ECDSA, for example)
in the same `SSL_CTX` context, which makes the code a bit convoluted.
12 files changed:
pdns/dnsdistdist/dnsdist-configuration-yaml.cc
pdns/dnsdistdist/dnsdist-lua.cc
pdns/dnsdistdist/doh.cc
pdns/dnsdistdist/doq-common.cc
pdns/libssl.cc
pdns/libssl.hh
pdns/tcpiohandler.cc
regression-tests.dnsdist/.gitignore
regression-tests.dnsdist/Makefile
regression-tests.dnsdist/configServer2.conf [new file with mode: 0644]
regression-tests.dnsdist/dnsdisttests.py
regression-tests.dnsdist/test_SNI.py