Skip to content

TLS session resumption support

Artem Boldariev requested to merge artem-client-tls-sessions-reuse into main

This merge request adds TLS session resumption to the TLS client-side code.

Resuming the previously saved session reduces the amount of data transmitted during TLS connection (re)establishment by up to a few kilobytes, which is significant in the context of DNS, where messages are, in general, small.

Here is a couple of examples (for 2048 bit RSA and Elliptic Curve certificates). The packet traces contain three sessions when A record for isc.org is being queried over TLS.

RSA 2048 - no TLS session resumption

no_resumption_rsa

RSA 2048 - TLS session resumption works as expected

resumption_rsa

In the case full handshake is being done, the full TCP session size is around 5700 bytes, while in case of TLS session resumption it gets reduced to around 1400 bytes.

EC - no TLS session resumption

no_resumption_ec

EC - TLS session resumption works as expected

resumption_ec

The savings are smaller, but very well measurable. In the case full handshake is being done, the full TCP session size is around 1900 bytes, while in case of TLS session resumption it gets reduced to around 1350 bytes.

In the named logs with debugging enables session resumption looks like follows:

09-May-2022 20:46:10.021 TLS server session created for 127.0.0.1#46865 on 127.0.0.1#44344
09-May-2022 20:46:10.031 TLS server session resumed for 127.0.0.1#41073 on 127.0.0.1#44344
09-May-2022 20:46:10.037 TLS server session resumed for 127.0.0.1#36389 on 127.0.0.1#44344

Currently, the optimisation applies to TLS-based DNS transports within dig and XoT functionality within BIND itself - on the side of the server TLS session caching is being done by default (and transparently by OpenSSL), but our own code was not making use of that. This merge request changes that.

In the case of dig, it is important because it brings its behaviour closer to that of WEB-browsers which implement that.

In the case of XoT, having TLS session resumption could make subsequent zone transfers more efficient.

It also provides a foundation for the efficient implementation of TLS forwarding in the future, where TLS session resumption is essential for getting good performance.

The functionality is built on top of the newly implemented TLS client session cache.

The changes also ensure that more sessions on the server-side are being correctly marked as successfully closed, improving the possibility of session resumption for third-party client software as well.

Edited by Artem Boldariev

Merge request reports