2016-11-22 17:13:44 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
2017-07-01 01:29:09 +02:00
|
|
|
if (!common.hasCrypto)
|
2016-11-22 17:13:44 +01:00
|
|
|
common.skip('missing crypto');
|
|
|
|
|
2017-07-01 01:29:09 +02:00
|
|
|
if (!common.hasIPv6)
|
2016-11-22 17:13:44 +01:00
|
|
|
common.skip('IPv6 support required');
|
|
|
|
|
2017-07-01 01:29:09 +02:00
|
|
|
const initHooks = require('./init-hooks');
|
|
|
|
const verifyGraph = require('./verify-graph');
|
2016-11-22 17:13:44 +01:00
|
|
|
const tls = require('tls');
|
2017-08-09 19:29:40 +02:00
|
|
|
const fixtures = require('../common/fixtures');
|
2017-07-01 01:29:09 +02:00
|
|
|
|
2016-11-22 17:13:44 +01:00
|
|
|
const hooks = initHooks();
|
|
|
|
hooks.enable();
|
|
|
|
|
|
|
|
//
|
|
|
|
// Creating server and listening on port
|
|
|
|
//
|
|
|
|
const server = tls
|
|
|
|
.createServer({
|
2019-05-29 20:43:44 +02:00
|
|
|
cert: fixtures.readKey('rsa_cert.crt'),
|
|
|
|
key: fixtures.readKey('rsa_private.pem')
|
2016-11-22 17:13:44 +01:00
|
|
|
})
|
|
|
|
.on('listening', common.mustCall(onlistening))
|
|
|
|
.on('secureConnection', common.mustCall(onsecureConnection))
|
2017-11-22 23:39:38 +01:00
|
|
|
.listen(0);
|
2016-11-22 17:13:44 +01:00
|
|
|
|
|
|
|
function onlistening() {
|
|
|
|
//
|
|
|
|
// Creating client and connecting it to server
|
|
|
|
//
|
|
|
|
tls
|
2017-11-22 23:39:38 +01:00
|
|
|
.connect(server.address().port, { rejectUnauthorized: false })
|
2016-11-22 17:13:44 +01:00
|
|
|
.on('secureConnect', common.mustCall(onsecureConnect));
|
|
|
|
}
|
|
|
|
|
|
|
|
function onsecureConnection() {}
|
|
|
|
|
|
|
|
function onsecureConnect() {
|
tls: support TLSv1.3
This introduces TLS1.3 support and makes it the default max protocol,
but also supports CLI/NODE_OPTIONS switches to disable it if necessary.
TLS1.3 is a major update to the TLS protocol, with many security
enhancements. It should be preferred over TLS1.2 whenever possible.
TLS1.3 is different enough that even though the OpenSSL APIs are
technically API/ABI compatible, that when TLS1.3 is negotiated, the
timing of protocol records and of callbacks broke assumptions hard-coded
into the 'tls' module.
This change introduces no API incompatibilities when TLS1.2 is
negotiated. It is the intention that it be backported to current and LTS
release lines with the default maximum TLS protocol reset to 'TLSv1.2'.
This will allow users of those lines to explicitly enable TLS1.3 if they
want.
API incompatibilities between TLS1.2 and TLS1.3 are:
- Renegotiation is not supported by TLS1.3 protocol, attempts to call
`.renegotiate()` will always fail.
- Compiling against a system OpenSSL lower than 1.1.1 is no longer
supported (OpenSSL-1.1.0 used to be supported with configure flags).
- Variations of `conn.write('data'); conn.destroy()` have undefined
behaviour according to the streams API. They may or may not send the
'data', and may or may not cause a ERR_STREAM_DESTROYED error to be
emitted. This has always been true, but conditions under which the write
suceeds is slightly but observably different when TLS1.3 is negotiated
vs when TLS1.2 or below is negotiated.
- If TLS1.3 is negotiated, and a server calls `conn.end()` in its
'secureConnection' listener without any data being written, the client
will not receive session tickets (no 'session' events will be emitted,
and `conn.getSession()` will never return a resumable session).
- The return value of `conn.getSession()` API may not return a resumable
session if called right after the handshake. The effect will be that
clients using the legacy `getSession()` API will resume sessions if
TLS1.2 is negotiated, but will do full handshakes if TLS1.3 is
negotiated. See https://github.com/nodejs/node/pull/25831 for more
information.
PR-URL: https://github.com/nodejs/node/pull/26209
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
2018-11-29 02:58:08 +01:00
|
|
|
// end() client socket, which causes slightly different hook events than
|
|
|
|
// destroy(), but with TLS1.3 destroy() rips the connection down before the
|
|
|
|
// server completes the handshake.
|
|
|
|
this.end();
|
2016-11-22 17:13:44 +01:00
|
|
|
|
|
|
|
// Closing server
|
|
|
|
server.close(common.mustCall(onserverClosed));
|
|
|
|
}
|
|
|
|
|
|
|
|
function onserverClosed() {}
|
|
|
|
|
|
|
|
process.on('exit', onexit);
|
|
|
|
|
|
|
|
function onexit() {
|
|
|
|
hooks.disable();
|
|
|
|
|
|
|
|
verifyGraph(
|
|
|
|
hooks,
|
2017-11-20 17:18:40 +01:00
|
|
|
[ { type: 'TCPSERVERWRAP', id: 'tcpserver:1', triggerAsyncId: null },
|
|
|
|
{ type: 'TCPWRAP', id: 'tcp:1', triggerAsyncId: 'tcpserver:1' },
|
|
|
|
{ type: 'TLSWRAP', id: 'tls:1', triggerAsyncId: 'tcpserver:1' },
|
2016-11-22 17:13:44 +01:00
|
|
|
{ type: 'GETADDRINFOREQWRAP',
|
2017-06-14 12:39:53 +02:00
|
|
|
id: 'getaddrinforeq:1', triggerAsyncId: 'tls:1' },
|
2016-11-22 17:13:44 +01:00
|
|
|
{ type: 'TCPCONNECTWRAP',
|
2017-11-20 17:18:40 +01:00
|
|
|
id: 'tcpconnect:1', triggerAsyncId: 'tcp:1' },
|
|
|
|
{ type: 'TCPWRAP', id: 'tcp:2', triggerAsyncId: 'tcpserver:1' },
|
|
|
|
{ type: 'TLSWRAP', id: 'tls:2', triggerAsyncId: 'tcpserver:1' },
|
tls: support TLSv1.3
This introduces TLS1.3 support and makes it the default max protocol,
but also supports CLI/NODE_OPTIONS switches to disable it if necessary.
TLS1.3 is a major update to the TLS protocol, with many security
enhancements. It should be preferred over TLS1.2 whenever possible.
TLS1.3 is different enough that even though the OpenSSL APIs are
technically API/ABI compatible, that when TLS1.3 is negotiated, the
timing of protocol records and of callbacks broke assumptions hard-coded
into the 'tls' module.
This change introduces no API incompatibilities when TLS1.2 is
negotiated. It is the intention that it be backported to current and LTS
release lines with the default maximum TLS protocol reset to 'TLSv1.2'.
This will allow users of those lines to explicitly enable TLS1.3 if they
want.
API incompatibilities between TLS1.2 and TLS1.3 are:
- Renegotiation is not supported by TLS1.3 protocol, attempts to call
`.renegotiate()` will always fail.
- Compiling against a system OpenSSL lower than 1.1.1 is no longer
supported (OpenSSL-1.1.0 used to be supported with configure flags).
- Variations of `conn.write('data'); conn.destroy()` have undefined
behaviour according to the streams API. They may or may not send the
'data', and may or may not cause a ERR_STREAM_DESTROYED error to be
emitted. This has always been true, but conditions under which the write
suceeds is slightly but observably different when TLS1.3 is negotiated
vs when TLS1.2 or below is negotiated.
- If TLS1.3 is negotiated, and a server calls `conn.end()` in its
'secureConnection' listener without any data being written, the client
will not receive session tickets (no 'session' events will be emitted,
and `conn.getSession()` will never return a resumable session).
- The return value of `conn.getSession()` API may not return a resumable
session if called right after the handshake. The effect will be that
clients using the legacy `getSession()` API will resume sessions if
TLS1.2 is negotiated, but will do full handshakes if TLS1.3 is
negotiated. See https://github.com/nodejs/node/pull/25831 for more
information.
PR-URL: https://github.com/nodejs/node/pull/26209
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
2018-11-29 02:58:08 +01:00
|
|
|
{ type: 'Immediate', id: 'immediate:1', triggerAsyncId: 'tcp:2' },
|
|
|
|
{ type: 'Immediate', id: 'immediate:2', triggerAsyncId: 'tcp:1' },
|
|
|
|
]
|
2016-11-22 17:13:44 +01:00
|
|
|
);
|
|
|
|
}
|