| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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_SYSTEM_TRUST_STORE_H_ | 5 #ifndef NET_CERT_INTERNAL_SYSTEM_TRUST_STORE_H_ |
| 6 #define NET_CERT_INTERNAL_SYSTEM_TRUST_STORE_H_ | 6 #define NET_CERT_INTERNAL_SYSTEM_TRUST_STORE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "net/base/net_export.h" | 11 #include "net/base/net_export.h" |
| 12 #include "net/cert/internal/parsed_certificate.h" | 12 #include "net/cert/internal/parsed_certificate.h" |
| 13 | 13 |
| 14 namespace net { | 14 namespace net { |
| 15 | 15 |
| 16 class TrustStore; | 16 class TrustStore; |
| 17 class CertIssuerSource; | |
| 18 class TrustAnchor; | |
| 19 | 17 |
| 20 // The SystemTrustStore interface is used to encapsulate a TrustStore for the | 18 // The SystemTrustStore interface is used to encapsulate a TrustStore for the |
| 21 // current platform, with some extra bells and whistles. | 19 // current platform, with some extra bells and whistles. |
| 22 // | 20 // |
| 23 // This is primarily used to abstract out the platform-specific bits that | 21 // This is primarily used to abstract out the platform-specific bits that |
| 24 // relate to configuring the TrustStore needed for path building. | 22 // relate to configuring the TrustStore needed for path building. |
| 25 // | 23 // |
| 26 // Implementations of SystemTrustStore create an effective trust | 24 // Implementations of SystemTrustStore create an effective trust |
| 27 // store that is the composition of: | 25 // store that is the composition of: |
| 28 // | 26 // |
| (...skipping 10 matching lines...) Expand all Loading... |
| 39 // valid only for the lifetime of |this|. | 37 // valid only for the lifetime of |this|. |
| 40 virtual TrustStore* GetTrustStore() = 0; | 38 virtual TrustStore* GetTrustStore() = 0; |
| 41 | 39 |
| 42 // Returns false if the implementation of SystemTrustStore doesn't actually | 40 // 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 | 41 // make use of the system's trust store. This might be the case for |
| 44 // unsupported platforms. In the case where this returns false, the trust | 42 // unsupported platforms. In the case where this returns false, the trust |
| 45 // store returned by GetTrustStore() is made up solely of the manually added | 43 // store returned by GetTrustStore() is made up solely of the manually added |
| 46 // trust anchors (via AddTrustAnchor()). | 44 // trust anchors (via AddTrustAnchor()). |
| 47 virtual bool UsesSystemTrustStore() const = 0; | 45 virtual bool UsesSystemTrustStore() const = 0; |
| 48 | 46 |
| 49 // TODO(eroman): Expose this through the TrustStore interface instead? | 47 // IsKnownRoot() returns true if the given certificate originated from the |
| 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 | 48 // 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 | 49 // 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 | 50 // user-installed one. |
| 62 // TrustAnchors returned by GetTrustStore(). | 51 virtual bool IsKnownRoot(const ParsedCertificate* cert) const = 0; |
| 63 virtual bool IsKnownRoot( | |
| 64 const scoped_refptr<TrustAnchor>& trust_anchor) const = 0; | |
| 65 | 52 |
| 66 // Adds a trust anchor to this particular instance of SystemTrustStore, and | 53 // Adds a trust anchor to this particular instance of SystemTrustStore, |
| 67 // not globally for the system. | 54 // and not globally for the system. |
| 68 virtual void AddTrustAnchor( | 55 virtual void AddTrustAnchor(const scoped_refptr<ParsedCertificate>& cert) = 0; |
| 69 const scoped_refptr<TrustAnchor>& trust_anchor) = 0; | |
| 70 | 56 |
| 71 // Returns true if |trust_anchor| was one added via |AddTrustAnchor()|. This | 57 // Returns true if |trust_anchor| was one added via |AddTrustAnchor()|. |
| 72 // is only guaranteed to work if |trust_anchor| was one returned by | 58 virtual bool IsAdditionalTrustAnchor(const ParsedCertificate* cert) const = 0; |
| 73 // GetTrustStore(), as it may be implemented by pointer comparison rather than | |
| 74 // SPKI comparison. | |
| 75 virtual bool IsAdditionalTrustAnchor( | |
| 76 const scoped_refptr<TrustAnchor>& trust_anchor) const = 0; | |
| 77 }; | 59 }; |
| 78 | 60 |
| 79 // Creates an instance of SystemTrustStore that wraps the current platform's SSL | 61 // Creates an instance of SystemTrustStore that wraps the current platform's SSL |
| 80 // trust store. This canno return nullptr, even in the case where system trust | 62 // trust store. This canno return nullptr, even in the case where system trust |
| 81 // store integration is not supported. In this latter case, the SystemTrustStore | 63 // store integration is not supported. In this latter case, the SystemTrustStore |
| 82 // will only give access to the manually added trust anchors. This can be | 64 // will only give access to the manually added trust anchors. This can be |
| 83 // inspected by testing whether UsesSystemTrustStore() returns false. | 65 // inspected by testing whether UsesSystemTrustStore() returns false. |
| 84 NET_EXPORT std::unique_ptr<SystemTrustStore> CreateSslSystemTrustStore(); | 66 NET_EXPORT std::unique_ptr<SystemTrustStore> CreateSslSystemTrustStore(); |
| 85 | 67 |
| 86 } // namespace net | 68 } // namespace net |
| 87 | 69 |
| 88 #endif // NET_CERT_INTERNAL_SYSTEM_TRUST_STORE_H_ | 70 #endif // NET_CERT_INTERNAL_SYSTEM_TRUST_STORE_H_ |
| OLD | NEW |