-
-
Save indutny/77c6145f86f272cf705a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 8e109b177b80871fde2d8dea43ef2e07842413b3 | |
Author: Fedor Indutny <fedor.indutny@gmail.com> | |
Date: Thu Mar 28 20:55:51 2013 +0400 | |
tls: handle SSL_ERROR_ZERO_RETURN | |
see #5004 | |
diff --git a/lib/tls.js b/lib/tls.js | |
index 3ec126e..5385912 100644 | |
--- a/lib/tls.js | |
+++ b/lib/tls.js | |
@@ -922,9 +922,13 @@ SecurePair.prototype.error = function(returnOnly) { | |
this.ssl.error = null; | |
if (!this._secureEstablished) { | |
- if (!err) { | |
- err = new Error('socket hang up'); | |
- err.code = 'ECONNRESET'; | |
+ // Emit ECONNRESET instead of zero return | |
+ if (!err || err.message === 'ZERO_RETURN') { | |
+ var connReset = new Error('socket hang up'); | |
+ connReset.code = 'ECONNRESET'; | |
+ connReset.sslError = err && err.message; | |
+ | |
+ err = connReset; | |
} | |
this.destroy(); | |
if (!returnOnly) this.emit('error', err); | |
diff --git a/src/node_crypto.cc b/src/node_crypto.cc | |
index c53d2ce..ec2dbe4 100644 | |
--- a/src/node_crypto.cc | |
+++ b/src/node_crypto.cc | |
@@ -927,6 +927,11 @@ int Connection::HandleSSLError(const char* func, int rv, ZeroStatus zs) { | |
DEBUG_PRINT("[%p] SSL: %s want read\n", ssl_, func); | |
return 0; | |
+ } else if (err == SSL_ERROR_ZERO_RETURN) { | |
+ handle_->Set(String::New("error"), | |
+ Exception::Error(String::New("ZERO_RETURN"))); | |
+ return rv; | |
+ | |
} else { | |
HandleScope scope; | |
BUF_MEM* mem; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment