Skip to content

Commit

Permalink
TLS/SSL: Socket emits 'error' event on handshake failure
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoder committed Oct 7, 2016
1 parent 0875565 commit a05872f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,11 @@ TLSSocket.prototype._init = function(socket, wrap) {

// Destroy socket if error happened before handshake's finish
if (!self._secureEstablished) {
self.destroy(self._tlsError(err));
if (!self._controlReleased) {
self.destroy(err);
} else {
self.destroy(self._tlsError(err));
}
} else if (options.isServer &&
rejectUnauthorized &&
/peer did not return a certificate/.test(err.message)) {
Expand Down

0 comments on commit a05872f

Please sign in to comment.