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() { SecurePair.prototype.error = function() {
var err = this.ssl.error;
this.ssl.error = null;
if (!this._secureEstablished) { if (!this._secureEstablished) {
var error = this.ssl.error; if (!err) {
if (!error) { err = new Error('socket hang up');
error = new Error('socket hang up'); err.code = 'ECONNRESET';
error.code = 'ECONNRESET';
} }
this.destroy(); this.destroy();
this.emit('error', error); this.emit('error', err);
return error; } else if (this._isServer &&
this._rejectUnauthorized &&
/peer did not return a certificate/.test(err.message)) {
// Not really an error.
this.destroy();
} else { } else {
var err = this.ssl.error; this.cleartext.emit('error', err);
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;
} }
return err;
}; };
// TODO: support anonymous (nocert) and PSK // TODO: support anonymous (nocert) and PSK

Loading…
Cancel
Save