Permalink
Browse files

tls: fix

  • Loading branch information...
1 parent b5ddc0c commit 315bba3b8449a72c6350cb6cf1648278047f1392 @indutny committed Mar 18, 2013
Showing with 8 additions and 9 deletions.
  1. +8 −9 lib/tls.js
View
@@ -906,19 +906,18 @@ 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);
+ return err;
} else {
- var err = this.ssl.error;
- this.ssl.error = null;
-
if (this._isServer &&
this._rejectUnauthorized &&
/peer did not return a certificate/.test(err.message)) {

0 comments on commit 315bba3

Please sign in to comment.