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

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

Issue 1976433002: Add new ParsedCertificate class, move TrustStore to own file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cert-parsing-remove-old-parsedcertificate
Patch Set: . Created 4 years, 7 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
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 #include "net/cert/internal/parsed_certificate.h"
8
9 namespace net {
10
11 TrustStore::TrustStore() {}
12 TrustStore::~TrustStore() {}
13
14 void TrustStore::Clear() {
15 anchors_.clear();
16 }
17
18 void TrustStore::AddTrustedCertificate(
19 scoped_refptr<ParsedCertificate> anchor) {
20 // TODO(mattm): should this check for duplicate certs?
21 anchors_.insert(
22 std::pair<base::StringPiece, scoped_refptr<ParsedCertificate>>(
23 anchor->normalized_subject(), std::move(anchor)));
24 }
25
26 void TrustStore::FindTrustAnchorsByNormalizedName(
27 const std::string& normalized_name,
28 std::vector<scoped_refptr<ParsedCertificate>>* matches) const {
29 auto range = anchors_.equal_range(normalized_name);
30 for (auto it = range.first; it != range.second; ++it)
31 matches->push_back(it->second);
32 }
33
34 bool TrustStore::IsTrustedCertificate(const ParsedCertificate* cert) const {
35 auto range = anchors_.equal_range(cert->normalized_subject());
36 for (auto it = range.first; it != range.second; ++it) {
37 // First compare the ParsedCertificate pointers as an optimization, fall
eroman 2016/05/12 18:12:30 Do we currently use this or is it just a nice-to-h
mattm 2016/05/13 02:17:37 In this CL it could be used if we add the anchor t
38 // back to comparing full DER encoding.
39 if (it->second == cert || it->second->der_cert() == cert->der_cert())
40 return true;
41 }
42 return false;
43 }
44
45 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698