فهرست منبع

squelch noisy "cert already in hash table" errors

David Rose 16 سال پیش
والد
کامیت
c8c51528bd
2فایلهای تغییر یافته به همراه32 افزوده شده و 3 حذف شده
  1. 31 3
      panda/src/express/openSSLWrapper.cxx
  2. 1 0
      panda/src/express/openSSLWrapper.h

+ 31 - 3
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

+ 1 - 0
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();