Browse Source

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
v0.10.1-release
Fedor Indutny 12 years ago
parent
commit
34e22b8ee7
  1. 33
      lib/tls.js

33
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

Loading…
Cancel
Save