Browse Source

tls: handle SSL_ERROR_ZERO_RETURN

see #5004
v0.10.2-release
Fedor Indutny 12 years ago
parent
commit
4580be0882
  1. 10
      lib/tls.js
  2. 5
      src/node_crypto.cc

10
lib/tls.js

@ -922,9 +922,13 @@ SecurePair.prototype.error = function(returnOnly) {
this.ssl.error = null; this.ssl.error = null;
if (!this._secureEstablished) { if (!this._secureEstablished) {
if (!err) { // Emit ECONNRESET instead of zero return
err = new Error('socket hang up'); if (!err || err.message === 'ZERO_RETURN') {
err.code = 'ECONNRESET'; var connReset = new Error('socket hang up');
connReset.code = 'ECONNRESET';
connReset.sslError = err && err.message;
err = connReset;
} }
this.destroy(); this.destroy();
if (!returnOnly) this.emit('error', err); if (!returnOnly) this.emit('error', err);

5
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); DEBUG_PRINT("[%p] SSL: %s want read\n", ssl_, func);
return 0; return 0;
} else if (err == SSL_ERROR_ZERO_RETURN) {
handle_->Set(String::New("error"),
Exception::Error(String::New("ZERO_RETURN")));
return rv;
} else { } else {
HandleScope scope; HandleScope scope;
BUF_MEM* mem; BUF_MEM* mem;

Loading…
Cancel
Save