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

Side by Side Diff: net/cert/internal/trust_store.cc

Issue 2126803004: WIP: NSS trust store integration for path builder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cert-command-line-path-builder-add_certpathbuilder
Patch Set: . Created 4 years, 4 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
« no previous file with comments | « net/cert/internal/trust_store.h ('k') | net/cert/internal/trust_store_collection.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "net/cert/internal/trust_store.h"
6
7 namespace net {
8
9 TrustStore::TrustStore() {}
10 TrustStore::~TrustStore() {}
11
12 void TrustStore::Clear() {
13 anchors_.clear();
14 }
15
16 void TrustStore::AddTrustedCertificate(
17 scoped_refptr<ParsedCertificate> anchor) {
18 // TODO(mattm): should this check for duplicate certs?
19 anchors_.insert(std::make_pair(anchor->normalized_subject().AsStringPiece(),
20 std::move(anchor)));
21 }
22
23 void TrustStore::FindTrustAnchorsByNormalizedName(
24 const der::Input& normalized_name,
25 ParsedCertificateList* matches) const {
26 auto range = anchors_.equal_range(normalized_name.AsStringPiece());
27 for (auto it = range.first; it != range.second; ++it)
28 matches->push_back(it->second);
29 }
30
31 bool TrustStore::IsTrustedCertificate(const ParsedCertificate* cert) const {
32 auto range = anchors_.equal_range(cert->normalized_subject().AsStringPiece());
33 for (auto it = range.first; it != range.second; ++it) {
34 // First compare the ParsedCertificate pointers as an optimization.
35 if (it->second == cert ||
36 // Trust check is based on Name+SPKI match. This could match the same
37 // certificate stored in a different ParsedCertificate object, or a
38 // different cert that has the same Name+SPKI.
39 (it->second->normalized_subject() == cert->normalized_subject() &&
40 it->second->tbs().spki_tlv == cert->tbs().spki_tlv))
41 return true;
42 }
43 return false;
44 }
45
46 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/internal/trust_store.h ('k') | net/cert/internal/trust_store_collection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698