mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
This was deprecated in 10.0.0 because NPN support was removed. It does not make sense to keep this around longer than 10.x PR-URL: https://github.com/nodejs/node/pull/20736 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
102 lines
2.4 KiB
JavaScript
102 lines
2.4 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
const tls = require('tls');
|
|
|
|
common.expectsError(
|
|
() => tls.createSecureContext({ ciphers: 1 }),
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
type: TypeError,
|
|
message: 'Ciphers must be a string'
|
|
});
|
|
|
|
common.expectsError(
|
|
() => tls.createServer({ ciphers: 1 }),
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
type: TypeError,
|
|
message: 'Ciphers must be a string'
|
|
});
|
|
|
|
common.expectsError(
|
|
() => tls.createSecureContext({ key: 'dummykey', passphrase: 1 }),
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
type: TypeError,
|
|
message: 'Pass phrase must be a string'
|
|
});
|
|
|
|
common.expectsError(
|
|
() => tls.createServer({ key: 'dummykey', passphrase: 1 }),
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
type: TypeError,
|
|
message: 'Pass phrase must be a string'
|
|
});
|
|
|
|
common.expectsError(
|
|
() => tls.createServer({ ecdhCurve: 1 }),
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
type: TypeError,
|
|
message: 'ECDH curve name must be a string'
|
|
});
|
|
|
|
common.expectsError(
|
|
() => tls.createServer({ handshakeTimeout: 'abcd' }),
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
type: TypeError,
|
|
message: 'The "options.handshakeTimeout" property must ' +
|
|
'be of type number. Received type string'
|
|
}
|
|
);
|
|
|
|
common.expectsError(
|
|
() => tls.createServer({ sessionTimeout: 'abcd' }),
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
type: TypeError,
|
|
message: 'Session timeout must be a 32-bit integer'
|
|
});
|
|
|
|
common.expectsError(
|
|
() => tls.createServer({ ticketKeys: 'abcd' }),
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
type: TypeError,
|
|
message: 'Ticket keys must be a buffer'
|
|
});
|
|
|
|
assert.throws(() => tls.createServer({ ticketKeys: Buffer.alloc(0) }),
|
|
/TypeError: Ticket keys length must be 48 bytes/);
|
|
|
|
common.expectsError(
|
|
() => tls.createSecurePair({}),
|
|
{
|
|
code: 'ERR_ASSERTION',
|
|
message: 'context.context must be a NativeSecureContext'
|
|
}
|
|
);
|
|
|
|
{
|
|
const buffer = Buffer.from('abcd');
|
|
const out = {};
|
|
tls.convertALPNProtocols(buffer, out);
|
|
out.ALPNProtocols.write('efgh');
|
|
assert(buffer.equals(Buffer.from('abcd')));
|
|
assert(out.ALPNProtocols.equals(Buffer.from('efgh')));
|
|
}
|
|
|
|
{
|
|
const buffer = new Uint8Array(Buffer.from('abcd'));
|
|
const out = {};
|
|
tls.convertALPNProtocols(buffer, out);
|
|
assert(out.ALPNProtocols.equals(Buffer.from('abcd')));
|
|
}
|