From 19e96c17f5cdfae62e90af32d1dbce029842a749 Mon Sep 17 00:00:00 2001 From: Christian Aurich Zanettini Martins Date: Fri, 13 Nov 2026 00:52:29 -0300 Subject: [PATCH] test: deflake test-tls-resume-servername The PSK server's pskCallback answered every identity, but OpenSSL also asks it about the resumption ticket, cut at its first NUL byte. When that prefix is valid UTF-8, about 1% of the time, the ticket was taken for an external PSK and the handshake failed with decrypt_error. Only answer for the identity the client sends. Signed-off-by: Christian Aurich Zanettini Martins --- test/parallel/test-tls-resume-servername.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-tls-resume-servername.js b/test/parallel/test-tls-resume-servername.js index 927ee597891c..0110739450e1 100644 --- a/test/parallel/test-tls-resume-servername.js +++ b/test/parallel/test-tls-resume-servername.js @@ -82,7 +82,11 @@ server.listen(0, common.mustCall(async () => { // TLS1.3 PSK works by pretending to be resumption (but it's not). const secret = Buffer.alloc(32, 1); const ciphers = 'TLS_AES_128_GCM_SHA256'; - const psk = tls.createServer({ ciphers, pskCallback: () => secret }, + // OpenSSL offers resumption tickets to pskCallback as identities too (cut + // at their first NUL byte). Answering those would turn a ticket into an + // external PSK whose binder can't verify, so only answer for 'client'. + const pskCallback = (socket, identity) => (identity === 'client' ? secret : undefined); + const psk = tls.createServer({ ciphers, pskCallback }, common.mustCall((socket) => { assert.strictEqual(socket.servername, 'psk.example'); socket.end();