OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/openssl_util.h" | 5 #include "base/openssl_util.h" |
6 | 6 |
7 #include <openssl/err.h> | 7 #include <openssl/err.h> |
8 #include <openssl/ssl.h> | 8 #include <openssl/ssl.h> |
9 | 9 |
10 #include "base/lock.h" | 10 #include "base/lock.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 DISALLOW_COPY_AND_ASSIGN(OpenSSLInitSingleton); | 61 DISALLOW_COPY_AND_ASSIGN(OpenSSLInitSingleton); |
62 }; | 62 }; |
63 | 63 |
64 } // namespace | 64 } // namespace |
65 | 65 |
66 void EnsureOpenSSLInit() { | 66 void EnsureOpenSSLInit() { |
67 (void)Singleton<OpenSSLInitSingleton>::get(); | 67 (void)Singleton<OpenSSLInitSingleton>::get(); |
68 } | 68 } |
69 | 69 |
70 void ClearOpenSSLERRStack() { | 70 void ClearOpenSSLERRStack(const char* message) { |
71 if (logging::DEBUG_MODE && VLOG_IS_ON(1)) { | 71 if (logging::DEBUG_MODE && VLOG_IS_ON(1)) { |
72 int error_num = ERR_get_error(); | 72 int error_num = ERR_get_error(); |
73 if (error_num == 0) | 73 if (error_num == 0) |
74 return; | 74 return; |
75 | 75 |
76 DVLOG(1) << "OpenSSL ERR_get_error stack:"; | 76 DVLOG(1) << "OpenSSL ERR_get_error stack: " << (message ? message : ""); |
77 char buf[140]; | 77 char buf[140]; |
78 do { | 78 do { |
79 ERR_error_string_n(error_num, buf, arraysize(buf)); | 79 ERR_error_string_n(error_num, buf, arraysize(buf)); |
80 DVLOG(1) << "\t" << error_num << ": " << buf; | 80 DVLOG(1) << "\t" << error_num << ": " << buf; |
81 error_num = ERR_get_error(); | 81 error_num = ERR_get_error(); |
82 } while (error_num != 0); | 82 } while (error_num != 0); |
83 } else { | 83 } else { |
84 ERR_clear_error(); | 84 ERR_clear_error(); |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
| 88 void ClearOpenSSLERRStack() { |
| 89 ClearOpenSSLERRStack(NULL); |
| 90 } |
| 91 |
88 } // namespace base | 92 } // namespace base |
OLD | NEW |