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
This commit is contained in:
parent
25eaacad9a
commit
34e22b8ee7
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…
x
Reference in New Issue
Block a user