From c8c51528bd0bef7f67c21052866e60a834e79004 Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 23 Oct 2009 04:40:57 +0000 Subject: [PATCH] squelch noisy "cert already in hash table" errors --- panda/src/express/openSSLWrapper.cxx | 34 +++++++++++++++++++++++++--- panda/src/express/openSSLWrapper.h | 1 + 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/panda/src/express/openSSLWrapper.cxx b/panda/src/express/openSSLWrapper.cxx index 8c01f649d3..0aa7445e9e 100644 --- a/panda/src/express/openSSLWrapper.cxx +++ b/panda/src/express/openSSLWrapper.cxx @@ -184,7 +184,7 @@ load_certificates_from_pem_ram(const char *data, size_t data_size) { if (itmp->x509) { int result = X509_STORE_add_cert(_x509_store, itmp->x509); if (result == 0) { - notify_ssl_errors(); + notify_debug_ssl_errors(); } else { ++count; } @@ -197,7 +197,7 @@ load_certificates_from_pem_ram(const char *data, size_t data_size) { } else if (itmp->crl) { int result = X509_STORE_add_crl(_x509_store, itmp->crl); if (result == 0) { - notify_ssl_errors(); + notify_debug_ssl_errors(); } else { ++count; } @@ -272,7 +272,7 @@ load_certificates_from_der_ram(const char *data, size_t data_size) { int result = X509_STORE_add_cert(_x509_store, x509); if (result == 0) { - notify_ssl_errors(); + notify_debug_ssl_errors(); } else { ++count; } @@ -335,6 +335,34 @@ notify_ssl_errors() { #endif // REPORT_OPENSSL_ERRORS } +//////////////////////////////////////////////////////////////////// +// Function: OpenSSLWrapper::notify_debug_ssl_errors +// Access: Public +// Description: As notify_ssl_errors(), but sends the output to debug +// instead of warning. +//////////////////////////////////////////////////////////////////// +void OpenSSLWrapper:: +notify_debug_ssl_errors() { +#ifdef REPORT_OPENSSL_ERRORS + static bool strings_loaded = false; + if (!strings_loaded) { + SSL_load_error_strings(); + strings_loaded = true; + } + + unsigned long e = ERR_get_error(); + while (e != 0) { + if (express_cat.is_debug()) { + static const size_t buffer_len = 256; + char buffer[buffer_len]; + ERR_error_string_n(e, buffer, buffer_len); + express_cat.debug() << buffer << "\n"; + } + e = ERR_get_error(); + } +#endif // REPORT_OPENSSL_ERRORS +} + //////////////////////////////////////////////////////////////////// // Function: OpenSSLWrapper::get_global_ptr // Access: Public, Static diff --git a/panda/src/express/openSSLWrapper.h b/panda/src/express/openSSLWrapper.h index 9045842138..5c47624786 100644 --- a/panda/src/express/openSSLWrapper.h +++ b/panda/src/express/openSSLWrapper.h @@ -54,6 +54,7 @@ public: X509_STORE *get_x509_store(); void notify_ssl_errors(); + void notify_debug_ssl_errors(); static OpenSSLWrapper *get_global_ptr();