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

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: . 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 #ifndef NET_CERT_INTERNAL_TRUST_STORE_H_
6 #define NET_CERT_INTERNAL_TRUST_STORE_H_
7
8 #include <string>
9 #include <unordered_map>
10 #include <vector>
11
12 #include "base/memory/ref_counted.h"
13 #include "base/strings/string_piece.h"
14 #include "net/base/net_export.h"
15
16 namespace net {
17
18 class ParsedCertificate;
19
20 // A very simple implementation of a TrustStore, which contains a set of
21 // trusted certificates.
22 // TODO(mattm): convert this into an interface, provide implementations that
23 // interface with OS trust store.
24 class NET_EXPORT TrustStore {
25 public:
26 TrustStore();
27 ~TrustStore();
28
29 // Empties the trust store, resetting it to original state.
30 void Clear();
31
32 // Adds a trusted certificate to the store.
33 void AddTrustedCertificate(scoped_refptr<ParsedCertificate> anchor);
34
35 // Returns the trust anchors that match |name| in |*matches|, if any.
36 void FindTrustAnchorsByNormalizedName(
37 const std::string& normalized_name,
38 std::vector<scoped_refptr<ParsedCertificate>>* matches) const;
eroman 2016/05/12 18:12:30 Should we make an alias for this somewhere? (appea
mattm 2016/05/13 02:17:37 I had one at one point, but it means you have to i
39
40 // Returns true if |cert| matches a certificate in the TrustStore.
41 bool IsTrustedCertificate(const ParsedCertificate* cert) const
42 WARN_UNUSED_RESULT;
43
44 private:
45 // Multimap from normalized subject -> ParsedCertificate.
46 std::unordered_multimap<base::StringPiece,
eroman 2016/05/12 18:12:30 Sounds good, however this may be problematic if we
mattm 2016/05/13 02:17:37 Good point, I'll keep that in mind.
47 scoped_refptr<ParsedCertificate>,
48 base::StringPieceHash>
49 anchors_;
50
51 DISALLOW_COPY_AND_ASSIGN(TrustStore);
52 };
53
54 } // namespace net
55
56 #endif // NET_CERT_INTERNAL_TRUST_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698