| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <cert.h> | 7 #include <cert.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 it != trust_cache_.rend(); ++it) { | 101 it != trust_cache_.rend(); ++it) { |
| 102 CERTCertTrust original_trust = (*it)->trust(); | 102 CERTCertTrust original_trust = (*it)->trust(); |
| 103 SECStatus rv = CERT_ChangeCertTrust(CERT_GetDefaultCertDB(), | 103 SECStatus rv = CERT_ChangeCertTrust(CERT_GetDefaultCertDB(), |
| 104 (*it)->certificate(), | 104 (*it)->certificate(), |
| 105 &original_trust); | 105 &original_trust); |
| 106 // DCHECK(), rather than LOG(), as a failure to restore the original | 106 // DCHECK(), rather than LOG(), as a failure to restore the original |
| 107 // trust can cause flake or hard-to-trace errors in any unit tests that | 107 // trust can cause flake or hard-to-trace errors in any unit tests that |
| 108 // occur after Clear() has been called. | 108 // occur after Clear() has been called. |
| 109 DCHECK_EQ(SECSuccess, rv) << "Cannot restore certificate trust."; | 109 DCHECK_EQ(SECSuccess, rv) << "Cannot restore certificate trust."; |
| 110 } | 110 } |
| 111 STLDeleteElements(&trust_cache_); | 111 base::STLDeleteElements(&trust_cache_); |
| 112 } | 112 } |
| 113 | 113 |
| 114 bool TestRootCerts::IsEmpty() const { | 114 bool TestRootCerts::IsEmpty() const { |
| 115 return trust_cache_.empty(); | 115 return trust_cache_.empty(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 #if defined(USE_NSS_CERTS) | 118 #if defined(USE_NSS_CERTS) |
| 119 bool TestRootCerts::Contains(CERTCertificate* cert) const { | 119 bool TestRootCerts::Contains(CERTCertificate* cert) const { |
| 120 for (std::list<TrustEntry*>::const_iterator it = trust_cache_.begin(); | 120 for (std::list<TrustEntry*>::const_iterator it = trust_cache_.begin(); |
| 121 it != trust_cache_.end(); ++it) { | 121 it != trust_cache_.end(); ++it) { |
| 122 if (X509Certificate::IsSameOSCert(cert, (*it)->certificate())) | 122 if (X509Certificate::IsSameOSCert(cert, (*it)->certificate())) |
| 123 return true; | 123 return true; |
| 124 } | 124 } |
| 125 return false; | 125 return false; |
| 126 } | 126 } |
| 127 #endif | 127 #endif |
| 128 | 128 |
| 129 TestRootCerts::~TestRootCerts() { | 129 TestRootCerts::~TestRootCerts() { |
| 130 Clear(); | 130 Clear(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void TestRootCerts::Init() { | 133 void TestRootCerts::Init() { |
| 134 crypto::EnsureNSSInit(); | 134 crypto::EnsureNSSInit(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 } // namespace net | 137 } // namespace net |
| OLD | NEW |