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

Side by Side Diff: net/cert/test_root_certs.h

Issue 137553004: NSS Cros multiprofile: trust roots added by a profile shouldn't apply to other profiles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ios fix Created 6 years, 10 months 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/cert/nss_profile_filter_chromeos_unittest.cc ('k') | net/cert/test_root_certs_nss.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef NET_CERT_TEST_ROOT_CERTS_H_ 5 #ifndef NET_CERT_TEST_ROOT_CERTS_H_
6 #define NET_CERT_TEST_ROOT_CERTS_H_ 6 #define NET_CERT_TEST_ROOT_CERTS_H_
7 7
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "net/base/net_export.h" 11 #include "net/base/net_export.h"
12 12
13 #if defined(USE_NSS) || defined(OS_IOS) 13 #if defined(USE_NSS) || defined(OS_IOS)
14 #include <list> 14 #include <list>
15 #elif defined(USE_OPENSSL) && !defined(OS_ANDROID) 15 #elif defined(USE_OPENSSL) && !defined(OS_ANDROID)
16 #include <vector> 16 #include <vector>
17 #elif defined(OS_WIN) 17 #elif defined(OS_WIN)
18 #include <windows.h> 18 #include <windows.h>
19 #include <wincrypt.h> 19 #include <wincrypt.h>
20 #elif defined(OS_MACOSX) 20 #elif defined(OS_MACOSX)
21 #include <CoreFoundation/CFArray.h> 21 #include <CoreFoundation/CFArray.h>
22 #include <Security/SecTrust.h> 22 #include <Security/SecTrust.h>
23 #include "base/mac/scoped_cftyperef.h" 23 #include "base/mac/scoped_cftyperef.h"
24 #endif 24 #endif
25 25
26 #if defined(USE_NSS)
27 typedef struct CERTCertificateStr CERTCertificate;
28 #elif defined(USE_OPENSSL) && !defined(OS_ANDROID)
29 typedef struct x509_st X509;
30 #endif
31
26 namespace base { 32 namespace base {
27 class FilePath; 33 class FilePath;
28 } 34 }
29 35
30 namespace net { 36 namespace net {
31 37
32 class X509Certificate; 38 class X509Certificate;
33 39
34 // TestRootCerts is a helper class for unit tests that is used to 40 // TestRootCerts is a helper class for unit tests that is used to
35 // artificially mark a certificate as trusted, independent of the local 41 // artificially mark a certificate as trusted, independent of the local
36 // machine configuration. 42 // machine configuration.
37 class NET_EXPORT_PRIVATE TestRootCerts { 43 class NET_EXPORT TestRootCerts {
38 public: 44 public:
39 // Obtains the Singleton instance to the trusted certificates. 45 // Obtains the Singleton instance to the trusted certificates.
40 static TestRootCerts* GetInstance(); 46 static TestRootCerts* GetInstance();
41 47
42 // Returns true if an instance exists, without forcing an initialization. 48 // Returns true if an instance exists, without forcing an initialization.
43 static bool HasInstance(); 49 static bool HasInstance();
44 50
45 // Marks |certificate| as trusted for X509Certificate::Verify(). Returns 51 // Marks |certificate| as trusted for X509Certificate::Verify(). Returns
46 // false if the certificate could not be marked trusted. 52 // false if the certificate could not be marked trusted.
47 bool Add(X509Certificate* certificate); 53 bool Add(X509Certificate* certificate);
48 54
49 // Reads a single certificate from |file| and marks it as trusted. Returns 55 // Reads a single certificate from |file| and marks it as trusted. Returns
50 // false if an error is encountered, such as being unable to read |file| 56 // false if an error is encountered, such as being unable to read |file|
51 // or more than one certificate existing in |file|. 57 // or more than one certificate existing in |file|.
52 bool AddFromFile(const base::FilePath& file); 58 bool AddFromFile(const base::FilePath& file);
53 59
54 // Clears the trusted status of any certificates that were previously 60 // Clears the trusted status of any certificates that were previously
55 // marked trusted via Add(). 61 // marked trusted via Add().
56 void Clear(); 62 void Clear();
57 63
58 // Returns true if there are no certificates that have been marked trusted. 64 // Returns true if there are no certificates that have been marked trusted.
59 bool IsEmpty() const; 65 bool IsEmpty() const;
60 66
61 #if defined(OS_MACOSX) && !defined(OS_IOS) 67 #if defined(USE_NSS)
68 bool Contains(CERTCertificate* cert) const;
69 #elif defined(OS_MACOSX) && !defined(OS_IOS)
62 CFArrayRef temporary_roots() const { return temporary_roots_; } 70 CFArrayRef temporary_roots() const { return temporary_roots_; }
63 71
64 // Modifies the root certificates of |trust_ref| to include the 72 // Modifies the root certificates of |trust_ref| to include the
65 // certificates stored in |temporary_roots_|. If IsEmpty() is true, this 73 // certificates stored in |temporary_roots_|. If IsEmpty() is true, this
66 // does not modify |trust_ref|. 74 // does not modify |trust_ref|.
67 OSStatus FixupSecTrustRef(SecTrustRef trust_ref) const; 75 OSStatus FixupSecTrustRef(SecTrustRef trust_ref) const;
68 76
69 // Configures whether or not the default/system root store should also 77 // Configures whether or not the default/system root store should also
70 // be trusted. By default, this is true, indicating that the TestRootCerts 78 // be trusted. By default, this is true, indicating that the TestRootCerts
71 // are used in addition to OS trust store. 79 // are used in addition to OS trust store.
72 void SetAllowSystemTrust(bool allow_system_trust); 80 void SetAllowSystemTrust(bool allow_system_trust);
73 #elif defined(USE_OPENSSL) && !defined(OS_ANDROID) 81 #elif defined(USE_OPENSSL) && !defined(OS_ANDROID)
74 const std::vector<scoped_refptr<X509Certificate> >& 82 const std::vector<scoped_refptr<X509Certificate> >&
75 temporary_roots() const { return temporary_roots_; } 83 temporary_roots() const { return temporary_roots_; }
84 bool Contains(X509* cert) const;
76 #elif defined(OS_WIN) 85 #elif defined(OS_WIN)
77 HCERTSTORE temporary_roots() const { return temporary_roots_; } 86 HCERTSTORE temporary_roots() const { return temporary_roots_; }
78 87
79 // Returns an HCERTCHAINENGINE suitable to be used for certificate 88 // Returns an HCERTCHAINENGINE suitable to be used for certificate
80 // validation routines, or NULL to indicate that the default system chain 89 // validation routines, or NULL to indicate that the default system chain
81 // engine is appropriate. The caller is responsible for freeing the 90 // engine is appropriate. The caller is responsible for freeing the
82 // returned HCERTCHAINENGINE. 91 // returned HCERTCHAINENGINE.
83 HCERTCHAINENGINE GetChainEngine() const; 92 HCERTCHAINENGINE GetChainEngine() const;
84 #endif 93 #endif
85 94
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 140
132 private: 141 private:
133 scoped_refptr<X509Certificate> cert_; 142 scoped_refptr<X509Certificate> cert_;
134 143
135 DISALLOW_COPY_AND_ASSIGN(ScopedTestRoot); 144 DISALLOW_COPY_AND_ASSIGN(ScopedTestRoot);
136 }; 145 };
137 146
138 } // namespace net 147 } // namespace net
139 148
140 #endif // NET_CERT_TEST_ROOT_CERTS_H_ 149 #endif // NET_CERT_TEST_ROOT_CERTS_H_
OLDNEW
« no previous file with comments | « net/cert/nss_profile_filter_chromeos_unittest.cc ('k') | net/cert/test_root_certs_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698