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. 21
      lib/tls.js

21
lib/tls.js

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

Loading…
Cancel
Save