diff options
author | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-12 22:30:50 +0000 |
---|---|---|
committer | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-12 22:30:50 +0000 |
commit | 84c498129a9c2ae8e642c04a9183d7077c159d41 (patch) | |
tree | 3484ca0c7f5509a078269b1c42fe8311cf01b6d9 /base/openssl_util.cc | |
parent | 0cf342c52abb85ccf8f8bdb97b21ab16d27d0eb4 (diff) | |
download | chromium_src-84c498129a9c2ae8e642c04a9183d7077c159d41.zip chromium_src-84c498129a9c2ae8e642c04a9183d7077c159d41.tar.gz chromium_src-84c498129a9c2ae8e642c04a9183d7077c159d41.tar.bz2 |
Log additional information when processing OpenSSL errors.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/5563009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68974 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/openssl_util.cc')
-rw-r--r-- | base/openssl_util.cc | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/base/openssl_util.cc b/base/openssl_util.cc index 5cfc34a..8d47609 100644 --- a/base/openssl_util.cc +++ b/base/openssl_util.cc @@ -11,6 +11,7 @@ #include "base/logging.h" #include "base/scoped_vector.h" #include "base/singleton.h" +#include "base/string_piece.h" namespace base { @@ -74,6 +75,20 @@ class OpenSSLInitSingleton { DISALLOW_COPY_AND_ASSIGN(OpenSSLInitSingleton); }; +// Callback routine for OpenSSL to print error messages. |str| is a +// NULL-terminated string of length |len| containing diagnostic information +// such as the library, function and reason for the error, the file and line +// where the error originated, plus potentially any context-specific +// information about the error. |context| contains a pointer to user-supplied +// data, which is currently unused. +// If this callback returns a value <= 0, OpenSSL will stop processing the +// error queue and return, otherwise it will continue calling this function +// until all errors have been removed from the queue. +int OpenSSLErrorCallback(const char* str, size_t len, void* context) { + DVLOG(1) << "\t" << StringPiece(str, len); + return 1; +} + } // namespace void EnsureOpenSSLInit() { @@ -82,19 +97,14 @@ void EnsureOpenSSLInit() { void ClearOpenSSLERRStack(const tracked_objects::Location& location) { if (logging::DEBUG_MODE && VLOG_IS_ON(1)) { - int error_num = ERR_get_error(); + int error_num = ERR_peek_error(); if (error_num == 0) return; std::string message; location.Write(true, true, &message); DVLOG(1) << "OpenSSL ERR_get_error stack from " << message; - char buf[140]; - do { - ERR_error_string_n(error_num, buf, arraysize(buf)); - DVLOG(1) << "\t" << error_num << ": " << buf; - error_num = ERR_get_error(); - } while (error_num != 0); + ERR_print_errors_cb(&OpenSSLErrorCallback, NULL); } else { ERR_clear_error(); } |