• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The Chromium Authors
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/cert/pki/trust_store_collection.h"
6 
7 namespace net {
8 
9 TrustStoreCollection::TrustStoreCollection() = default;
10 TrustStoreCollection::~TrustStoreCollection() = default;
11 
AddTrustStore(TrustStore * store)12 void TrustStoreCollection::AddTrustStore(TrustStore* store) {
13   DCHECK(store);
14   stores_.push_back(store);
15 }
16 
SyncGetIssuersOf(const ParsedCertificate * cert,ParsedCertificateList * issuers)17 void TrustStoreCollection::SyncGetIssuersOf(const ParsedCertificate* cert,
18                                             ParsedCertificateList* issuers) {
19   for (auto* store : stores_) {
20     store->SyncGetIssuersOf(cert, issuers);
21   }
22 }
23 
GetTrust(const ParsedCertificate * cert,base::SupportsUserData * debug_data)24 CertificateTrust TrustStoreCollection::GetTrust(
25     const ParsedCertificate* cert,
26     base::SupportsUserData* debug_data) {
27   // The current aggregate result.
28   CertificateTrust result = CertificateTrust::ForUnspecified();
29 
30   for (auto* store : stores_) {
31     CertificateTrust cur_trust = store->GetTrust(cert, debug_data);
32 
33     // * If any stores distrust the certificate, consider it untrusted.
34     // * If multiple stores consider it trusted, use the trust result from the
35     //   last one
36     if (!cur_trust.HasUnspecifiedTrust()) {
37       result = cur_trust;
38       if (result.IsDistrusted())
39         break;
40     }
41   }
42 
43   return result;
44 }
45 
46 }  // namespace net
47