Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: net/base/test_root_certs.cc

Issue 4646001: Implement LoadTemporaryRoot for Windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/net/base
Patch Set: Widen suppresions Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/test_root_certs.h ('k') | net/base/test_root_certs_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "net/base/test_root_certs.h"
6
7 #include <string>
8
9 #include "base/file_path.h"
10 #include "base/file_util.h"
11 #include "base/logging.h"
12 #include "net/base/x509_certificate.h"
13
14 namespace net {
15
16 namespace {
17
18 bool g_has_instance = false;
19
20 base::LazyInstance<TestRootCerts,
21 base::LeakyLazyInstanceTraits<TestRootCerts> >
22 g_test_root_certs(base::LINKER_INITIALIZED);
23
24 CertificateList LoadCertificates(const FilePath& filename) {
25 std::string raw_cert;
26 if (!file_util::ReadFileToString(filename, &raw_cert)) {
27 LOG(ERROR) << "Can't load certificate " << filename.value();
28 return CertificateList();
29 }
30
31 return X509Certificate::CreateCertificateListFromBytes(
32 raw_cert.data(), raw_cert.length(), X509Certificate::FORMAT_AUTO);
33 }
34
35 } // namespace
36
37 // static
38 TestRootCerts* TestRootCerts::GetInstance() {
39 return g_test_root_certs.Pointer();
40 }
41
42 bool TestRootCerts::HasInstance() {
43 return g_has_instance;
44 }
45
46 bool TestRootCerts::AddFromFile(const FilePath& file) {
47 CertificateList root_certs = LoadCertificates(file);
48 if (root_certs.empty() || root_certs.size() > 1)
49 return false;
50
51 return Add(root_certs.front());
52 }
53
54 TestRootCerts::TestRootCerts() {
55 Init();
56 g_has_instance = true;
57 }
58
59 } // namespace net
OLDNEW
« no previous file with comments | « net/base/test_root_certs.h ('k') | net/base/test_root_certs_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698