| 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 #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/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
| 13 | 13 |
| 14 #if defined(USE_NSS_VERIFIER) | 14 #if defined(USE_NSS_CERTS) |
| 15 #include <list> | 15 #include <list> |
| 16 #elif defined(USE_OPENSSL_CERTS) && !defined(OS_ANDROID) | 16 #elif defined(USE_OPENSSL_CERTS) && !defined(OS_ANDROID) |
| 17 #include <vector> | 17 #include <vector> |
| 18 #elif defined(OS_WIN) | 18 #elif defined(OS_WIN) |
| 19 #include <windows.h> | 19 #include <windows.h> |
| 20 #include "crypto/wincrypt_shim.h" | 20 #include "crypto/wincrypt_shim.h" |
| 21 #elif defined(OS_MACOSX) | 21 #elif defined(OS_MACOSX) |
| 22 #include <CoreFoundation/CFArray.h> | 22 #include <CoreFoundation/CFArray.h> |
| 23 #include <Security/SecTrust.h> | 23 #include <Security/SecTrust.h> |
| 24 #include "base/mac/scoped_cftyperef.h" | 24 #include "base/mac/scoped_cftyperef.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 // Clears the trusted status of any certificates that were previously | 61 // Clears the trusted status of any certificates that were previously |
| 62 // marked trusted via Add(). | 62 // marked trusted via Add(). |
| 63 void Clear(); | 63 void Clear(); |
| 64 | 64 |
| 65 // Returns true if there are no certificates that have been marked trusted. | 65 // Returns true if there are no certificates that have been marked trusted. |
| 66 bool IsEmpty() const; | 66 bool IsEmpty() const; |
| 67 | 67 |
| 68 #if defined(USE_NSS_CERTS) | 68 #if defined(USE_NSS_CERTS) |
| 69 bool Contains(CERTCertificate* cert) const; | 69 bool Contains(CERTCertificate* cert) const; |
| 70 #elif defined(OS_MACOSX) && !defined(USE_NSS_VERIFIER) | 70 #elif defined(OS_MACOSX) && !defined(USE_NSS_CERTS) |
| 71 CFArrayRef temporary_roots() const { return temporary_roots_; } | 71 CFArrayRef temporary_roots() const { return temporary_roots_; } |
| 72 | 72 |
| 73 // Modifies the root certificates of |trust_ref| to include the | 73 // Modifies the root certificates of |trust_ref| to include the |
| 74 // certificates stored in |temporary_roots_|. If IsEmpty() is true, this | 74 // certificates stored in |temporary_roots_|. If IsEmpty() is true, this |
| 75 // does not modify |trust_ref|. | 75 // does not modify |trust_ref|. |
| 76 OSStatus FixupSecTrustRef(SecTrustRef trust_ref) const; | 76 OSStatus FixupSecTrustRef(SecTrustRef trust_ref) const; |
| 77 | 77 |
| 78 // Configures whether or not the default/system root store should also | 78 // Configures whether or not the default/system root store should also |
| 79 // be trusted. By default, this is true, indicating that the TestRootCerts | 79 // be trusted. By default, this is true, indicating that the TestRootCerts |
| 80 // are used in addition to OS trust store. | 80 // are used in addition to OS trust store. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 95 | 95 |
| 96 private: | 96 private: |
| 97 friend struct base::DefaultLazyInstanceTraits<TestRootCerts>; | 97 friend struct base::DefaultLazyInstanceTraits<TestRootCerts>; |
| 98 | 98 |
| 99 TestRootCerts(); | 99 TestRootCerts(); |
| 100 ~TestRootCerts(); | 100 ~TestRootCerts(); |
| 101 | 101 |
| 102 // Performs platform-dependent initialization. | 102 // Performs platform-dependent initialization. |
| 103 void Init(); | 103 void Init(); |
| 104 | 104 |
| 105 #if defined(USE_NSS_VERIFIER) | 105 #if defined(USE_NSS_CERTS) |
| 106 // It is necessary to maintain a cache of the original certificate trust | 106 // It is necessary to maintain a cache of the original certificate trust |
| 107 // settings, in order to restore them when Clear() is called. | 107 // settings, in order to restore them when Clear() is called. |
| 108 class TrustEntry; | 108 class TrustEntry; |
| 109 std::list<TrustEntry*> trust_cache_; | 109 std::list<TrustEntry*> trust_cache_; |
| 110 #elif defined(USE_OPENSSL_CERTS) && !defined(OS_ANDROID) | 110 #elif defined(USE_OPENSSL_CERTS) && !defined(OS_ANDROID) |
| 111 std::vector<scoped_refptr<X509Certificate> > temporary_roots_; | 111 std::vector<scoped_refptr<X509Certificate> > temporary_roots_; |
| 112 #elif defined(OS_WIN) | 112 #elif defined(OS_WIN) |
| 113 HCERTSTORE temporary_roots_; | 113 HCERTSTORE temporary_roots_; |
| 114 #elif defined(OS_MACOSX) | 114 #elif defined(OS_MACOSX) |
| 115 base::ScopedCFTypeRef<CFMutableArrayRef> temporary_roots_; | 115 base::ScopedCFTypeRef<CFMutableArrayRef> temporary_roots_; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 141 | 141 |
| 142 private: | 142 private: |
| 143 scoped_refptr<X509Certificate> cert_; | 143 scoped_refptr<X509Certificate> cert_; |
| 144 | 144 |
| 145 DISALLOW_COPY_AND_ASSIGN(ScopedTestRoot); | 145 DISALLOW_COPY_AND_ASSIGN(ScopedTestRoot); |
| 146 }; | 146 }; |
| 147 | 147 |
| 148 } // namespace net | 148 } // namespace net |
| 149 | 149 |
| 150 #endif // NET_CERT_TEST_ROOT_CERTS_H_ | 150 #endif // NET_CERT_TEST_ROOT_CERTS_H_ |
| OLD | NEW |