| 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 "net/base/test_root_certs.h" | 5 #include "net/base/test_root_certs.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "net/base/x509_certificate.h" | 12 #include "net/base/x509_certificate.h" |
| 13 | 13 |
| 14 namespace net { | 14 namespace net { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 bool g_has_instance = false; | 18 bool g_has_instance = false; |
| 19 | 19 |
| 20 base::LazyInstance<TestRootCerts, | 20 base::LazyInstance<TestRootCerts, |
| 21 base::LeakyLazyInstanceTraits<TestRootCerts> > | 21 base::LeakyLazyInstanceTraits<TestRootCerts> > |
| 22 g_test_root_certs(base::LINKER_INITIALIZED); | 22 g_test_root_certs = LAZY_INSTANCE_INITIALIZER; |
| 23 | 23 |
| 24 CertificateList LoadCertificates(const FilePath& filename) { | 24 CertificateList LoadCertificates(const FilePath& filename) { |
| 25 std::string raw_cert; | 25 std::string raw_cert; |
| 26 if (!file_util::ReadFileToString(filename, &raw_cert)) { | 26 if (!file_util::ReadFileToString(filename, &raw_cert)) { |
| 27 LOG(ERROR) << "Can't load certificate " << filename.value(); | 27 LOG(ERROR) << "Can't load certificate " << filename.value(); |
| 28 return CertificateList(); | 28 return CertificateList(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 return X509Certificate::CreateCertificateListFromBytes( | 31 return X509Certificate::CreateCertificateListFromBytes( |
| 32 raw_cert.data(), raw_cert.length(), X509Certificate::FORMAT_AUTO); | 32 raw_cert.data(), raw_cert.length(), X509Certificate::FORMAT_AUTO); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 50 | 50 |
| 51 return Add(root_certs.front()); | 51 return Add(root_certs.front()); |
| 52 } | 52 } |
| 53 | 53 |
| 54 TestRootCerts::TestRootCerts() { | 54 TestRootCerts::TestRootCerts() { |
| 55 Init(); | 55 Init(); |
| 56 g_has_instance = true; | 56 g_has_instance = true; |
| 57 } | 57 } |
| 58 | 58 |
| 59 } // namespace net | 59 } // namespace net |
| OLD | NEW |