Skip to content

Commit 5d51de3

Browse files
christianaurichzmaduh95
authored andcommitted
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 <christian.aurichzm@gmail.com> PR-URL: #67450 Refs: nodejs/reliability#1722 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: LiviaMedeiros <livia@cirno.name>
1 parent e3caf97 commit 5d51de3

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎test/parallel/test-tls-resume-servername.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ server.listen(0, common.mustCall(async () => {
8282
// TLS1.3 PSK works by pretending to be resumption (but it's not).
8383
const secret = Buffer.alloc(32, 1);
8484
const ciphers = 'TLS_AES_128_GCM_SHA256';
85-
const psk = tls.createServer({ ciphers, pskCallback: () => secret },
85+
// OpenSSL offers resumption tickets to pskCallback as identities too (cut
86+
// at their first NUL byte). Answering those would turn a ticket into an
87+
// external PSK whose binder can't verify, so only answer for 'client'.
88+
const pskCallback = (socket, identity) => (identity === 'client' ? secret : undefined);
89+
const psk = tls.createServer({ ciphers, pskCallback },
8690
common.mustCall((socket) => {
8791
assert.strictEqual(socket.servername, 'psk.example');
8892
socket.end();

0 commit comments

Comments
 (0)