-
-
Save indutny/c9b000994f11a9ff626e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit d99156015ee584a6c61a8c4b450d6f2e83a2e5e6 | |
Author: Fedor Indutny <fedor.indutny@gmail.com> | |
Date: Wed Mar 20 17:35:38 2013 +0400 | |
tls: always reset this.ssl.error after handling | |
Otherwise assertion may happen. | |
diff --git a/lib/tls.js b/lib/tls.js | |
index ab80fb1..409d7da 100644 | |
--- a/lib/tls.js | |
+++ b/lib/tls.js | |
@@ -906,30 +906,25 @@ SecurePair.prototype.destroy = function() { | |
SecurePair.prototype.error = function() { | |
+ var err = this.ssl.error; | |
+ this.ssl.error = null; | |
+ | |
if (!this._secureEstablished) { | |
- var error = this.ssl.error; | |
- if (!error) { | |
- error = new Error('socket hang up'); | |
- error.code = 'ECONNRESET'; | |
+ if (!err) { | |
+ err = new Error('socket hang up'); | |
+ err.code = 'ECONNRESET'; | |
} | |
this.destroy(); | |
- this.emit('error', error); | |
- return error; | |
+ this.emit('error', err); | |
+ } else if (this._isServer && | |
+ this._rejectUnauthorized && | |
+ /peer did not return a certificate/.test(err.message)) { | |
+ // Not really an error. | |
+ this.destroy(); | |
} else { | |
- var err = this.ssl.error; | |
- this.ssl.error = null; | |
- | |
- if (this._isServer && | |
- this._rejectUnauthorized && | |
- /peer did not return a certificate/.test(err.message)) { | |
- // Not really an error. | |
- this.destroy(); | |
- } else { | |
- this.cleartext.emit('error', err); | |
- } | |
- | |
- return err; | |
+ this.cleartext.emit('error', err); | |
} | |
+ return err; | |
}; | |
// TODO: support anonymous (nocert) and PSK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment