mirror of
https://github.com/nodejs/node.git
synced 2025-05-09 03:18:24 +00:00

Add the `pskCallback` client/server option, which resolves an identity or identity hint to a pre-shared key. Add the `pskIdentityHint` server option to set the identity hint for the ServerKeyExchange message. Co-authored-by: Chris Osborn <chris.osborn@sitelier.com> Co-authored-by: stephank <gh@stephank.nl> Co-authored-by: Taylor Zane Glaeser <tzglaeser@gmail.com> PR-URL: https://github.com/nodejs/node/pull/23188 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
33 lines
848 B
JavaScript
33 lines
848 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_IDENTIY_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' }));
|
|
});
|
|
}
|