Browse Source

TLS: Simplify error handling

v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
3e58696c07
  1. 32
      lib/tls.js

32
lib/tls.js

@ -196,11 +196,7 @@ CryptoStream.prototype._push = function() {
chunkBytes = this._pusher(pool, bytesRead, pool.length - bytesRead);
if (this.pair._ssl && this.pair._ssl.error) {
if (this.pair._secureEstablished) {
this.pair._error();
} else {
this.pair._destroy();
}
this.pair._error();
return;
}
@ -277,11 +273,7 @@ CryptoStream.prototype._pull = function() {
var rv = this._puller(tmp);
if (this.pair._ssl && this.pair._ssl.error) {
if (this.pair._secureEstablished) {
this.pair._error();
} else {
this.pair._destroy();
}
this.pair._error();
return;
}
@ -500,16 +492,20 @@ SecurePair.prototype._destroy = function() {
SecurePair.prototype._error = function() {
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.
if (!this._secureEstablished) {
this._destroy();
} else {
this.cleartext.emit('error', err);
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);
}
}
};

Loading…
Cancel
Save