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

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

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: ScopedCheckUnreferencedCerts Created 4 years, 6 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 #ifndef NET_CERT_INTERNAL_TRUST_STORE_H_
6 #define NET_CERT_INTERNAL_TRUST_STORE_H_
7
8 #include <unordered_map>
9 #include <vector>
10
11 #include "base/memory/ref_counted.h"
12 #include "base/strings/string_piece.h"
13 #include "net/base/net_export.h"
14
15 namespace net {
16
17 namespace der {
18 class Input;
19 }
20
21 class ParsedCertificate;
22
23 // A very simple implementation of a TrustStore, which contains a set of
24 // trusted certificates.
25 // TODO(mattm): convert this into an interface, provide implementations that
26 // interface with OS trust store.
27 class NET_EXPORT TrustStore {
28 public:
29 TrustStore();
30 ~TrustStore();
31
32 // Empties the trust store, resetting it to original state.
33 void Clear();
34
35 // Adds a trusted certificate to the store.
36 void AddTrustedCertificate(scoped_refptr<ParsedCertificate> anchor);
37
38 // Returns the trust anchors that match |name| in |*matches|, if any.
39 void FindTrustAnchorsByNormalizedName(
40 const der::Input& normalized_name,
41 std::vector<scoped_refptr<ParsedCertificate>>* matches) const;
42
43 // Returns true if |cert| matches a certificate in the TrustStore.
44 bool IsTrustedCertificate(const ParsedCertificate* cert) const
45 WARN_UNUSED_RESULT;
46
47 private:
48 // Multimap from normalized subject -> ParsedCertificate.
49 std::unordered_multimap<base::StringPiece,
50 scoped_refptr<ParsedCertificate>,
51 base::StringPieceHash>
52 anchors_;
53
54 DISALLOW_COPY_AND_ASSIGN(TrustStore);
55 };
56
57 } // namespace net
58
59 #endif // NET_CERT_INTERNAL_TRUST_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698