tls: better error message for socket disconnect
The error emitted when a connection is closed before the TLS handshake completes seemed rather unspefic by just saying `socket hang up`. Use a more verbose message, that also indicates that this is a purely client-side error, and remove a misleading comment. PR-URL: https://github.com/nodejs/node/pull/18989 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
parent
1ebd966d2c
commit
eda702104b
@ -1074,7 +1074,6 @@ function onConnectSecure() {
|
||||
this.emit('secureConnect');
|
||||
}
|
||||
|
||||
// Uncork incoming data
|
||||
this.removeListener('end', onConnectEnd);
|
||||
}
|
||||
|
||||
@ -1083,7 +1082,8 @@ function onConnectEnd() {
|
||||
if (!this._hadError) {
|
||||
const options = this[kConnectOptions];
|
||||
this._hadError = true;
|
||||
const error = new Error('socket hang up');
|
||||
const error = new Error('Client network socket disconnected before ' +
|
||||
'secure TLS connection was established');
|
||||
error.code = 'ECONNRESET';
|
||||
error.path = options.path;
|
||||
error.host = options.host;
|
||||
|
@ -29,6 +29,6 @@ const server = tls.createServer(options, (c) => {
|
||||
}, common.mustNotCall());
|
||||
|
||||
c.on('error', common.mustCall((err) => {
|
||||
assert(/socket hang up/.test(err.message));
|
||||
assert(/Client network socket disconnected/.test(err.message));
|
||||
}));
|
||||
}));
|
||||
|
@ -175,7 +175,9 @@ process.on('exit', function() {
|
||||
]);
|
||||
assert.deepStrictEqual(clientResults, [true, true, true, false, false]);
|
||||
assert.deepStrictEqual(clientErrors, [
|
||||
null, null, null, null, 'socket hang up'
|
||||
null, null, null, null,
|
||||
'Client network socket disconnected before secure TLS ' +
|
||||
'connection was established'
|
||||
]);
|
||||
assert.deepStrictEqual(serverErrors, [
|
||||
null, null, null, null, 'Invalid SNI context'
|
||||
|
Loading…
x
Reference in New Issue
Block a user