Skip to content

Commit 6312e88

Browse files
committed
Drain OpenSSL error queue? Addresses #1719
1 parent e06ce75 commit 6312e88

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/node_crypto.cc

+12-1
Original file line numberDiff line numberDiff line change
@@ -504,11 +504,22 @@ int Connection::HandleSSLError(const char* func, int rv) {
504504
static char ssl_error_buf[512];
505505
ERR_error_string_n(err, ssl_error_buf, sizeof(ssl_error_buf));
506506

507+
// XXX We need to drain the error queue for this thread or else OpenSSL
508+
// has the possibility of blocking connections? This problem is not well
509+
// understood. And we should be somehow propigating these errors up
510+
// into JavaScript. There is no test which demonstrates this problem.
511+
// https://github.com/joyent/node/issues/1719
512+
while ((err = ERR_get_error()) != 0) {
513+
ERR_error_string_n(err, ssl_error_buf, sizeof(ssl_error_buf));
514+
fprintf(stderr, "(node SSL) %s\n", ssl_error_buf);
515+
}
516+
507517
HandleScope scope;
508518
Local<Value> e = Exception::Error(String::New(ssl_error_buf));
509519
handle_->Set(String::New("error"), e);
510520

511-
DEBUG_PRINT("[%p] SSL: %s failed: (%d:%d) %s\n", ssl_, func, err, rv, ssl_error_buf);
521+
DEBUG_PRINT("[%p] SSL: %s failed: (%d:%d) %s\n", ssl_, func, err, rv,
522+
ssl_error_buf);
512523

513524
return rv;
514525
}

0 commit comments

Comments
 (0)