Skip to content

Commit 4580be0

Browse files
committed
tls: handle SSL_ERROR_ZERO_RETURN
see #5004
1 parent 39058be commit 4580be0

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

lib/tls.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -922,9 +922,13 @@ SecurePair.prototype.error = function(returnOnly) {
922922
this.ssl.error = null;
923923

924924
if (!this._secureEstablished) {
925-
if (!err) {
926-
err = new Error('socket hang up');
927-
err.code = 'ECONNRESET';
925+
// Emit ECONNRESET instead of zero return
926+
if (!err || err.message === 'ZERO_RETURN') {
927+
var connReset = new Error('socket hang up');
928+
connReset.code = 'ECONNRESET';
929+
connReset.sslError = err && err.message;
930+
931+
err = connReset;
928932
}
929933
this.destroy();
930934
if (!returnOnly) this.emit('error', err);

src/node_crypto.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,11 @@ int Connection::HandleSSLError(const char* func, int rv, ZeroStatus zs) {
927927
DEBUG_PRINT("[%p] SSL: %s want read\n", ssl_, func);
928928
return 0;
929929

930+
} else if (err == SSL_ERROR_ZERO_RETURN) {
931+
handle_->Set(String::New("error"),
932+
Exception::Error(String::New("ZERO_RETURN")));
933+
return rv;
934+
930935
} else {
931936
HandleScope scope;
932937
BUF_MEM* mem;

0 commit comments

Comments
 (0)