OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/cert/test_root_certs.h" | 5 #include "net/cert/test_root_certs.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "net/cert/x509_certificate.h" | 12 #include "net/cert/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>::Leaky | 20 base::LazyInstance<TestRootCerts>::Leaky |
21 g_test_root_certs = LAZY_INSTANCE_INITIALIZER; | 21 g_test_root_certs = LAZY_INSTANCE_INITIALIZER; |
22 | 22 |
23 CertificateList LoadCertificates(const base::FilePath& filename) { | 23 CertificateList LoadCertificates(const base::FilePath& filename) { |
| 24 #if defined(OS_NACL) |
| 25 NOTIMPLEMENTED(); |
| 26 return CertificateList(); |
| 27 #else |
24 std::string raw_cert; | 28 std::string raw_cert; |
25 if (!base::ReadFileToString(filename, &raw_cert)) { | 29 if (!base::ReadFileToString(filename, &raw_cert)) { |
26 LOG(ERROR) << "Can't load certificate " << filename.value(); | 30 LOG(ERROR) << "Can't load certificate " << filename.value(); |
27 return CertificateList(); | 31 return CertificateList(); |
28 } | 32 } |
29 | 33 |
30 return X509Certificate::CreateCertificateListFromBytes( | 34 return X509Certificate::CreateCertificateListFromBytes( |
31 raw_cert.data(), raw_cert.length(), X509Certificate::FORMAT_AUTO); | 35 raw_cert.data(), raw_cert.length(), X509Certificate::FORMAT_AUTO); |
| 36 #endif |
32 } | 37 } |
33 | 38 |
34 } // namespace | 39 } // namespace |
35 | 40 |
36 // static | 41 // static |
37 TestRootCerts* TestRootCerts::GetInstance() { | 42 TestRootCerts* TestRootCerts::GetInstance() { |
38 return g_test_root_certs.Pointer(); | 43 return g_test_root_certs.Pointer(); |
39 } | 44 } |
40 | 45 |
41 bool TestRootCerts::HasInstance() { | 46 bool TestRootCerts::HasInstance() { |
(...skipping 25 matching lines...) Expand all Loading... |
67 | 72 |
68 void ScopedTestRoot::Reset(X509Certificate* cert) { | 73 void ScopedTestRoot::Reset(X509Certificate* cert) { |
69 if (cert_.get()) | 74 if (cert_.get()) |
70 TestRootCerts::GetInstance()->Clear(); | 75 TestRootCerts::GetInstance()->Clear(); |
71 if (cert) | 76 if (cert) |
72 TestRootCerts::GetInstance()->Add(cert); | 77 TestRootCerts::GetInstance()->Add(cert); |
73 cert_ = cert; | 78 cert_ = cert; |
74 } | 79 } |
75 | 80 |
76 } // namespace net | 81 } // namespace net |
OLD | NEW |