-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
Expand file tree
/
Copy pathtest-tls-psk-errors.js
More file actions
32 lines (28 loc) · 849 Bytes
/
test-tls-psk-errors.js
File metadata and controls
32 lines (28 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'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' }));
});
}