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

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

Issue 2832703002: Allow the TrustStore interface to return matching intermediates, and identify distrusted certs. (Closed)
Patch Set: fix cert_verify_tool Created 3 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
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 #ifndef NET_CERT_INTERNAL_TRUST_STORE_IN_MEMORY_H_ 5 #ifndef NET_CERT_INTERNAL_TRUST_STORE_IN_MEMORY_H_
6 #define NET_CERT_INTERNAL_TRUST_STORE_IN_MEMORY_H_ 6 #define NET_CERT_INTERNAL_TRUST_STORE_IN_MEMORY_H_
7 7
8 #include <unordered_map> 8 #include <unordered_map>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/strings/string_piece.h" 11 #include "base/strings/string_piece.h"
12 #include "net/base/net_export.h" 12 #include "net/base/net_export.h"
13 #include "net/cert/internal/trust_store.h" 13 #include "net/cert/internal/trust_store.h"
14 14
15 namespace net { 15 namespace net {
16 16
17 // A very simple implementation of a TrustStore, which contains a set of 17 // A very simple implementation of a TrustStore, which contains a set of
18 // trust anchors. 18 // certificates and their trustedness.
19 class NET_EXPORT TrustStoreInMemory : public TrustStore { 19 class NET_EXPORT TrustStoreInMemory : public TrustStore {
20 public: 20 public:
21 TrustStoreInMemory(); 21 TrustStoreInMemory();
22 ~TrustStoreInMemory() override; 22 ~TrustStoreInMemory() override;
23 23
24 // Empties the trust store, resetting it to original state. 24 // Empties the trust store, resetting it to original state.
25 void Clear(); 25 void Clear();
26 26
27 void AddTrustAnchor(scoped_refptr<TrustAnchor> anchor); 27 // Adds a certificate as a trust anchor (only the SPKI and subject will be
28 // used during verification).
29 void AddTrustAnchor(scoped_refptr<ParsedCertificate> cert);
30
31 // Adds a certificate as a trust achor and extracts anchor constraints from
32 // the certificate. See VerifyCertificateChain for details.
33 void AddTrustAnchorWithConstraints(scoped_refptr<ParsedCertificate> cert);
34
35 // Adds a certificate with the specified trust settings.
36 void AddCertificate(scoped_refptr<ParsedCertificate> cert,
37 const CertificateTrust& trust);
28 38
29 // TrustStore implementation: 39 // TrustStore implementation:
30 void FindTrustAnchorsForCert(const scoped_refptr<ParsedCertificate>& cert, 40 void SyncGetIssuersOf(const ParsedCertificate* cert,
31 TrustAnchors* matches) const override; 41 ParsedCertificateList* issuers) override;
42 void GetTrust(const scoped_refptr<ParsedCertificate>& cert,
43 CertificateTrust* trust) const override;
32 44
33 // Returns true if the trust store contains the given TrustAnchor instance. 45 // Returns true if the trust store contains the given ParsedCertificate
34 // Note that this considers only pointer equality and not a more 46 // (matches by DER).
35 // broad notion of equivalence based on the object's content. 47 bool Contains(const ParsedCertificate* cert) const;
36 bool Contains(const TrustAnchor* anchor) const;
37 48
38 private: 49 private:
39 // Multimap from normalized subject -> TrustAnchor. 50 struct Entry {
40 std::unordered_multimap<base::StringPiece, 51 Entry();
41 scoped_refptr<TrustAnchor>, 52 Entry(const Entry& other);
42 base::StringPieceHash> 53 ~Entry();
43 anchors_; 54
55 scoped_refptr<ParsedCertificate> cert;
56 CertificateTrust trust;
57 };
58
59 // Multimap from normalized subject -> Entry.
60 std::unordered_multimap<base::StringPiece, Entry, base::StringPieceHash>
61 entries_;
44 62
45 DISALLOW_COPY_AND_ASSIGN(TrustStoreInMemory); 63 DISALLOW_COPY_AND_ASSIGN(TrustStoreInMemory);
46 }; 64 };
47 65
48 } // namespace net 66 } // namespace net
49 67
50 #endif // NET_CERT_INTERNAL_TRUST_STORE_IN_MEMORY_H_ 68 #endif // NET_CERT_INTERNAL_TRUST_STORE_IN_MEMORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698