0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-tls-psk-errors.js
Aviv Keller f666a1b754
tls: fix 'ERR_TLS_PSK_SET_IDENTIY_HINT_FAILED' typo
Co-Authored-By: Fabian Iwand <mootari@users.noreply.github.com>
PR-URL: https://github.com/nodejs/node/pull/52627
Fixes: https://github.com/nodejs/node/issues/52448
Refs: https://github.com/nodejs/node/pull/23188
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2024-09-20 17:59:22 +00:00

33 lines
849 B
JavaScript

'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const tls = require('tls');
{
// Check tlsClientError on invalid pskIdentityHint.
const server = tls.createServer({
ciphers: 'PSK+HIGH',
pskCallback: () => {},
pskIdentityHint: 'a'.repeat(512), // Too long identity hint.
});
server.on('tlsClientError', (err) => {
assert.ok(err instanceof Error);
assert.strictEqual(err.code, 'ERR_TLS_PSK_SET_IDENTITY_HINT_FAILED');
server.close();
});
server.listen(0, () => {
const client = tls.connect({
port: server.address().port,
ciphers: 'PSK+HIGH',
checkServerIdentity: () => {},
pskCallback: () => {},
}, () => {});
client.on('error', common.expectsError({ code: 'ECONNRESET' }));
});
}