Hello Daniel,

Thanks for the quick answer.

About the pool timeout: the ticket used by the failing refresh is never old in the pool, only its chain is.

- At each refresh, knot_tls_req_ctx_init() takes the ticket out of the pool, and knot_tls_req_ctx_maint() puts back the ticket of the new session. pool_push() sets last_active at that moment, so with a refresh every 300 s, no ticket stays in the pool more than 300 s, and the 1200 s timeout never runs out. The pool is created with conn_pool_invalid_cb_allvalid(), so nothing checks the ticket's own lifetime.
- But GnuTLS does not give the ticket of a resumed session a new 6 hours: it caps it at the original full handshake plus 6 hours (generate_session_ticket() in lib/tls13/session_ticket.c).
- So the ticket put in the pool at 13:41:11 was valid only until 13:46:09, for 298 s. It was taken at 13:46:11, after 300 s in the pool, 2 s after it had expired.

The pool timeout would only drop such a ticket if the refreshes were more than 1200 s apart. The fallback you mention would cover our case.

One more detail, in case it helps: in GnuTLS 3.8.3, the client drops a ticket older than its lifetime before the ClientHello (client_send_params() in lib/ext/pre_shared_key.c), and gnutls_session_set_data() restores that lifetime and arrival time. So the failing handshake probably does not even offer the ticket, and still fails.

Thanks,
Thomas

Le mar. 10 nov. 2026 à 17:29, Daniel Salzman <daniel.salzman@nic.cz> a écrit :
Hello,

We haven't implemented the fallback from a failed resumption attempt to a full handshake yet.
You're correct, 6 hours is the default ticket validity period in GnuTLS.
What I don't understand is why an expired ticket is being taken from the ticket pool,
because the pool timeout is set to 1200 seconds.

We'll improve this in the future.

Daniel

On 11/10/26 11:02, Thomas Tourtet via knot-dns-users wrote:
> Hello,
>
> We run Knot DNS with one hidden primary and four secondaries. Zone
> transfers and NOTIFY go over XoT, with TSIG. Every secondary fails one
> refresh about every 6 hours with "handshake failed", and the retry 60 s
> later succeeds. We think we see why, and would like to know whether this
> is known, and whether Knot could fall back to a full handshake instead.
>
> Has it worked before? It has done this for as long as we have looked
> (since early November), on all four secondaries. We changed nothing that
> could have started it.
>
> Versions and platform, the same on all five servers:
> - Knot DNS 3.6.2-cznic.1~noble, from the CZ.NIC repository
> - GnuTLS 3.8.3-1.1ubuntu3.6 (Ubuntu package)
> - Ubuntu 24.04, kernel 6.8.0-146/147-generic, KVM virtual machines
>
> What one secondary logs (anonymized, times in UTC):
>
>    13:41:11.612 info: [example.net <http://example.net>.] refresh, remote 192.0.2.1@853 TLS/0-RTT, key xfr-key., remote serial 1793875167, zone is up-to-date, expires in 1209600 seconds
>    13:46:11.613 info: [example.net <http://example.net>.] refresh, remote primary, address 192.0.2.1@853, failed (handshake failed)
>    13:46:11.614 warning: [example.net <http://example.net>.] refresh, remote primary not usable
>    13:46:11.614 error: [example.net <http://example.net>.] refresh, failed (no usable master), next retry at 2026-11-09T07:47:11-0600, expires in 1209300 seconds
>    13:46:11.614 error: [example.net <http://example.net>.] zone event 'refresh' failed (no usable master)
>    13:47:11.617 info: [example.net <http://example.net>.] refresh, remote 192.0.2.1@853 TLS, key xfr-key., remote serial 1793875167, zone is up-to-date, expires in 1209600 seconds
>
> The cycle on that secondary, on 2026-11-09:
> - 07:46:09: a refresh with a full handshake ("TLS", without 0-RTT).
> - Then 71 refreshes over "TLS/0-RTT", one every 300 s
>    (refresh-max-interval), the last at 13:41:11.
> - 13:46:11, 21602 s after the full handshake: "handshake failed". It is
>    logged about 1 ms after the refresh starts, with a sub-millisecond RTT
>    to the primary, so it comes on the first exchange, not from a timeout.
> - 13:47:11, after retry-max-interval (60 s): a full handshake again, and
>    a new cycle starts.
>
> The time between two failures is about 21662 s: 6 hours, plus the 60 s
> retry, plus the time the refreshes take. All four secondaries follow
> this cycle, each with its own phase. The primary was not restarted in
> that time, and its reloads did not cause failures.
>
> What we think happens:
> - tls-requestor.c takes the pooled session ticket of the remote, loads
>    it, and enables early data (KNOT_TLS_EARLY_DATA). After each exchange,
>    the new session goes back to the pool.
> - On a resumed session, GnuTLS caps the lifetime of the ticket it issues
>    at the start of the original session plus expire_time
>    (lib/tls13/session_ticket.c: "ensure that we don't extend the lifetime
>    of the ticket past the original session expiration time"). Knot does
>    not set expire_time, so the GnuTLS default of 21600 s applies: a chain
>    of resumptions ends 6 hours after its full handshake.
> - The first refresh after that point fails with a fatal GnuTLS error
>    (KNOT_NET_EHSHAKE, "handshake failed") instead of falling back to a
>    full handshake. We have not captured which GnuTLS error it is.
>
> Impact: low. The retry succeeds a minute later. But each secondary logs
> a warning and two errors every 6 hours, and a check on failed refreshes
> has to tolerate them.
>
> Expected: when the stored ticket can no longer be used, the refresh does
> a full handshake instead of failing.
>
> To reproduce: a primary and a secondary with XoT as below, and any
> refresh interval shorter than 6 hours. The first refresh more than 6
> hours after the first full handshake fails.
>
> Configuration, anonymized. keys.conf holds the TSIG keys and is left
> out. The secondaries also load mod-geoip and mod-stats, which we think
> are unrelated.
>
> Secondary:
>
>    server:
>        listen: [ 192.0.2.11@53 ]
>        listen-tls: [ 192.0.2.11@853 ]
>
>    remote:
>      - id: primary
>        address: 192.0.2.1@853
>        key: xfr-key.
>        tls: on
>        via: 192.0.2.11
>
>    acl:
>      - id: notify_from_primary
>        address: 192.0.2.1
>        key: [ xfr-key. ]
>        protocol: tls
>        action: notify
>
>    template:
>      - id: default
>        refresh-max-interval: 300
>        retry-max-interval: 60
>
>    zone:
>      - domain: example.net <http://example.net>
>        master: primary
>        acl: notify_from_primary
>
> Primary:
>
>    server:
>        listen: [ 192.0.2.1@53 ]
>        listen-tls: [ 192.0.2.1@853 ]
>
>    remote:
>      - id: secondary1
>        address: 192.0.2.11@853
>        key: xfr-key.
>        tls: on
>      # secondary2 to secondary4 alike
>
>    acl:
>      - id: transfer
>        address: [ 192.0.2.11, 192.0.2.12, 192.0.2.13, 192.0.2.14 ]
>        key: [ xfr-key. ]
>        protocol: tls
>        action: transfer
>
>    zone:
>      - domain: example.net <http://example.net>
>        notify: [ secondary1, secondary2, secondary3, secondary4 ]
>        acl: [ transfer ]
>
> If it helps, we can send logs at debug level around a failure, or a
> packet capture of a failing handshake.
>
> Thanks,
> Thomas
>
> --