Permalink
Browse files

crypto: look up SSL errors with ERR_print_errors()

  • Loading branch information...
1 parent 3aa1975 commit 64e39e8f6ff5f17b45dbf59fd2c6e789bf7df8f2 @bnoordhuis committed Sep 19, 2011
Showing with 12 additions and 13 deletions.
  1. +12 −13 src/node_crypto.cc
View
@@ -533,26 +533,25 @@ int Connection::HandleSSLError(const char* func, int rv) {
return 0;
} else {
- static char ssl_error_buf[512];
- ERR_error_string_n(err, ssl_error_buf, sizeof(ssl_error_buf));
+ HandleScope scope;
+ BUF_MEM* mem;
+ BIO *bio;
+
+ assert(err == SSL_ERROR_SSL || err == SSL_ERROR_SYSCALL);
// XXX We need to drain the error queue for this thread or else OpenSSL
// has the possibility of blocking connections? This problem is not well
- // understood. And we should be somehow propigating these errors up
+ // understood. And we should be somehow propagating these errors up
// into JavaScript. There is no test which demonstrates this problem.
// https://github.com/joyent/node/issues/1719
- while ((err = ERR_get_error()) != 0) {
- ERR_error_string_n(err, ssl_error_buf, sizeof(ssl_error_buf));
- fprintf(stderr, "(node SSL) %s\n", ssl_error_buf);
+ if ((bio = BIO_new(BIO_s_mem()))) {
+ ERR_print_errors(bio);
+ BIO_get_mem_ptr(bio, &mem);
+ Local<Value> e = Exception::Error(String::New(mem->data, mem->length));
+ handle_->Set(String::New("error"), e);
+ BIO_free(bio);
}
- HandleScope scope;
- Local<Value> e = Exception::Error(String::New(ssl_error_buf));
- handle_->Set(String::New("error"), e);
-
- DEBUG_PRINT("[%p] SSL: %s failed: (%d:%d) %s\n", ssl_, func, err, rv,
- ssl_error_buf);
-
return rv;
}

0 comments on commit 64e39e8

Please sign in to comment.