Index: net/base/test_root_certs_openssl.cc |
diff --git a/net/base/test_root_certs_openssl.cc b/net/base/test_root_certs_openssl.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7d9953185ff79bf765d629fdb74b946860b9fc1d |
--- /dev/null |
+++ b/net/base/test_root_certs_openssl.cc |
@@ -0,0 +1,50 @@ |
+// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "net/base/test_root_certs.h" |
+ |
+#include <openssl/err.h> |
+#include <openssl/x509v3.h> |
+ |
+#include "base/logging.h" |
+#include "net/base/openssl_util.h" |
+#include "net/base/x509_certificate.h" |
+ |
+namespace net { |
+ |
+bool TestRootCerts::Add(X509Certificate* certificate) { |
+ OpenSSLInitSingleton* openssl_init = GetOpenSSLInitSingleton(); |
+ |
+ if (!X509_STORE_add_cert(openssl_init->x509_store(), |
+ certificate->os_cert_handle())) { |
+ unsigned long error_code = ERR_get_error(); |
+ if (ERR_GET_LIB(error_code) != ERR_LIB_X509 || |
+ ERR_GET_REASON(error_code) != X509_R_CERT_ALREADY_IN_HASH_TABLE) { |
+ do { |
+ LOG(ERROR) << "X509_STORE_add_cert error: " << error_code; |
+ } while ((error_code = ERR_get_error()) != 0); |
joth
2010/11/17 16:29:20
minor suggestion: you can now just call ClearOpenS
|
+ return false; |
+ } |
+ } |
+ |
+ empty_ = false; |
+ return true; |
+} |
+ |
+void TestRootCerts::Clear() { |
+ OpenSSLInitSingleton* openssl_init = GetOpenSSLInitSingleton(); |
+ openssl_init->ReinitializeStore(); |
joth
2010/11/17 16:29:20
ah sorry I competely missed this when I sent the l
|
+ empty_ = true; |
+} |
+ |
+bool TestRootCerts::IsEmpty() const { |
+ return empty_; |
+} |
+ |
+TestRootCerts::TestRootCerts() |
+ : empty_(true) {} |
bulach
2010/11/17 17:17:30
nit: \n}
Ryan Sleevi
2010/11/18 05:31:58
Looking at http://google-styleguide.googlecode.com
|
+ |
+TestRootCerts::~TestRootCerts() {} |
bulach
2010/11/17 17:17:30
nit: \n}
Ryan Sleevi
2010/11/18 05:31:58
Judging by http://crrev.com/61100 , I see the orig
|
+ |
+} // namespace net |