OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/internal/trust_store_collection.h" | 5 #include "net/cert/internal/trust_store_collection.h" |
6 | 6 |
7 namespace net { | 7 namespace net { |
8 | 8 |
9 TrustStoreCollection::TrustStoreCollection() = default; | 9 TrustStoreCollection::TrustStoreCollection() = default; |
10 TrustStoreCollection::~TrustStoreCollection() = default; | 10 TrustStoreCollection::~TrustStoreCollection() = default; |
11 | 11 |
12 void TrustStoreCollection::AddTrustStore(TrustStore* store) { | 12 void TrustStoreCollection::AddTrustStore(TrustStore* store) { |
13 DCHECK(store); | 13 DCHECK(store); |
14 stores_.push_back(store); | 14 stores_.push_back(store); |
15 } | 15 } |
16 | 16 |
17 void TrustStoreCollection::FindTrustAnchorsForCert( | 17 void TrustStoreCollection::SyncGetIssuersOf(const ParsedCertificate* cert, |
18 const scoped_refptr<ParsedCertificate>& cert, | 18 ParsedCertificateList* issuers) { |
19 TrustAnchors* matches) const { | |
20 for (auto* store : stores_) { | 19 for (auto* store : stores_) { |
21 store->FindTrustAnchorsForCert(cert, matches); | 20 store->SyncGetIssuersOf(cert, issuers); |
22 } | 21 } |
23 } | 22 } |
24 | 23 |
24 void TrustStoreCollection::GetTrust( | |
25 const scoped_refptr<ParsedCertificate>& cert, | |
26 CertificateTrust* out_trust) const { | |
27 // The current aggregate result. | |
28 CertificateTrust result = CertificateTrust::Unspecified(); | |
29 | |
30 for (auto* store : stores_) { | |
31 CertificateTrust cur_trust; | |
32 store->GetTrust(cert, &cur_trust); | |
33 | |
34 // * If any stores distrust the certificate, consider it untrusted. | |
35 // * If multiple stores consider it trusted, use the trust result from first | |
mattm
2017/04/28 20:26:47
doesn't it use the result from the last one?
eroman
2017/04/28 21:48:03
You are correct. Updated the comment.
| |
36 // one. | |
37 if (!cur_trust.HasUnspecifiedTrust()) { | |
38 result = cur_trust; | |
39 if (result.IsDistrusted()) | |
40 break; | |
41 } | |
42 } | |
43 | |
44 *out_trust = result; | |
45 } | |
46 | |
25 } // namespace net | 47 } // namespace net |
OLD | NEW |