diff options
author | Fedor Indutny <fedor.indutny@gmail.com> | 2013-03-20 17:35:38 +0400 |
---|---|---|
committer | Fedor Indutny <fedor.indutny@gmail.com> | 2013-03-20 17:58:01 +0400 |
commit | 34e22b8ee742b4529c6982f8631fc07522d8197f (patch) | |
tree | 9504c729ccd4d70643cf7c5ba2113f5ac0256681 | |
parent | 25eaacad9a14c27465dc65e15e3a5eb5544031e6 (diff) | |
download | node-new-34e22b8ee742b4529c6982f8631fc07522d8197f.tar.gz |
tls: always reset this.ssl.error after handling
Otherwise assertion may happen:
src/node_crypto.cc:962: void node::crypto::Connection::ClearError():
Assertion `handle_->Get(String::New("error"))->BooleanValue() == false'
failed.
See #5058
-rw-r--r-- | lib/tls.js | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/lib/tls.js b/lib/tls.js index ab80fb1817..409d7da5c5 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 |