Skip to content

Commit a05872f

Browse files
committed
TLS/SSL: Socket emits 'error' event on handshake failure
Fixes: nodejs#8803
1 parent 0875565 commit a05872f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/_tls_wrap.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,11 @@ TLSSocket.prototype._init = function(socket, wrap) {
426426

427427
// Destroy socket if error happened before handshake's finish
428428
if (!self._secureEstablished) {
429-
self.destroy(self._tlsError(err));
429+
if (!self._controlReleased) {
430+
self.destroy(err);
431+
} else {
432+
self.destroy(self._tlsError(err));
433+
}
430434
} else if (options.isServer &&
431435
rejectUnauthorized &&
432436
/peer did not return a certificate/.test(err.message)) {

0 commit comments

Comments
 (0)