Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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_SYSTEM_TRUST_STORE_H_ | |
| 6 #define NET_CERT_INTERNAL_SYSTEM_TRUST_STORE_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/memory/ref_counted.h" | |
| 11 #include "net/base/net_export.h" | |
| 12 #include "net/cert/internal/parsed_certificate.h" | |
| 13 | |
| 14 namespace net { | |
| 15 | |
| 16 class TrustStore; | |
| 17 class CertIssuerSource; | |
| 18 class TrustAnchor; | |
| 19 | |
| 20 // The SystemTrustStore interface is used to encapsulate a TrustStore for the | |
| 21 // current platform, with some extra bells and whistles. | |
| 22 // | |
| 23 // This is primarily used to abstract out the platform-specific bits that | |
| 24 // relate to configuring the TrustStore needed for path building. | |
| 25 // | |
| 26 // Implementations of SystemTrustStore create an effective trust | |
| 27 // store that is the composition of: | |
| 28 // | |
| 29 // * The platform-specific trust store | |
| 30 // * A set of manually added trust anchors | |
| 31 // * Test certificates added via ScopedTestRoot | |
| 32 class SystemTrustStore { | |
| 33 public: | |
| 34 virtual ~SystemTrustStore() {} | |
| 35 | |
| 36 // Returns an aggregate TrustStore that can be used by the path builder. The | |
| 37 // store composes the system trust store (if implemented) with manually added | |
| 38 // trust anchors added via AddTrustAnchor(). This pointer is non-owned, and | |
| 39 // valid only for the lifetime of |this|. | |
| 40 virtual TrustStore* GetTrustStore() = 0; | |
| 41 | |
| 42 // Returns false if the implementation of SystemTrustStore doesn't actually | |
| 43 // make use of the system's trust store. This might be the case for | |
| 44 // unsupported platforms. In the case where this returns true, the trust store | |
|
mattm
2017/04/19 20:26:04
true here should be false?
eroman
2017/04/19 21:10:41
Done.
| |
| 45 // returned by GetTrustStore() is made up solely of the manually added trust | |
| 46 // anchors (via AddTrustAnchor()). | |
| 47 virtual bool UsesSystemTrustStore() const = 0; | |
| 48 | |
| 49 // TODO(eroman): Expose this through the TrustStore interface instead? | |
| 50 // | |
| 51 // Returns a CertIssuerSource that finds any intermediates that are present in | |
| 52 // the system trust store. These intermediates are not necessarily trusted, | |
| 53 // however may be used during path building as another means of finding | |
| 54 // certificates. If the implementation of SystemTrustStore doesn't support | |
| 55 // this feature may return nullptr. | |
| 56 virtual CertIssuerSource* GetCertIssuerSource() = 0; | |
| 57 | |
| 58 // IsKnownRoot() returns true if the given trust anchor originated from the | |
| 59 // system trust store and is a "standard" one. The meaning of "standard" is | |
| 60 // that it is one of default trust anchors for the system, as opposed to a | |
| 61 // user-installed one. IsKnownRoot() is only guaranteed to work for | |
| 62 // TrustAnchors returned by GetTrustStore(). | |
| 63 virtual bool IsKnownRoot( | |
| 64 const scoped_refptr<TrustAnchor>& trust_anchor) const = 0; | |
| 65 | |
| 66 // Adds a trust anchor to this particular instance of SystemTrustStore, and | |
| 67 // not globally for the system. Calling this should not have a persistent | |
| 68 // effect on the system, however some implementations may implement this in a | |
| 69 // manner that has a global effect within the process. | |
|
mattm
2017/04/19 20:26:04
Is there a use case in mind for having one with a
eroman
2017/04/19 21:10:41
I am just documenting how things currently work (f
mattm
2017/04/19 21:36:00
Well, I guess it is true that ScopedTestRoot works
eroman
2017/04/19 21:42:53
Oh apologies, yes my comment is wrong I will remov
eroman
2017/04/19 21:45:06
Done.
| |
| 70 virtual void AddTrustAnchor( | |
| 71 const scoped_refptr<TrustAnchor>& trust_anchor) = 0; | |
| 72 | |
| 73 // Returns true if |trust_anchor| was one added via |AddTrustAnchor()|. This | |
| 74 // is only guaranteed to work if |trust_anchor| was one returned by | |
| 75 // GetTrustStore(), as it may be implemented by pointer comparison rather than | |
| 76 // SPKI comparison. | |
| 77 virtual bool IsAdditionalTrustAnchor( | |
| 78 const scoped_refptr<TrustAnchor>& trust_anchor) const = 0; | |
| 79 }; | |
| 80 | |
| 81 // Creates an instance of SystemTrustStore that wraps the current platform's SSL | |
| 82 // trust store. This canno return nullptr, even in the case where system trust | |
| 83 // store integration is not supported. In this latter case, the SystemTrustStore | |
| 84 // will only give access to the manually added trust anchors. This can be | |
| 85 // inspected by testing whether UsesSystemTrustStore() returns false. | |
| 86 NET_EXPORT std::unique_ptr<SystemTrustStore> CreateSslSystemTrustStore(); | |
| 87 | |
| 88 } // namespace net | |
| 89 | |
| 90 #endif // NET_CERT_INTERNAL_SYSTEM_TRUST_STORE_H_ | |
| OLD | NEW |