Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CERT_VERIFIER_H_ | 5 #ifndef NET_CERT_CERT_VERIFIER_H_ |
| 6 #define NET_CERT_CERT_VERIFIER_H_ | 6 #define NET_CERT_CERT_VERIFIER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "net/base/completion_callback.h" | 11 #include "net/base/completion_callback.h" |
| 12 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
| 13 | 13 |
| 14 namespace net { | 14 namespace net { |
| 15 | 15 |
| 16 class BoundNetLog; | 16 class BoundNetLog; |
| 17 class CertVerifyProc; | |
| 17 class CertVerifyResult; | 18 class CertVerifyResult; |
| 18 class CRLSet; | 19 class CRLSet; |
| 19 class X509Certificate; | 20 class X509Certificate; |
| 20 | 21 |
| 21 // CertVerifier represents a service for verifying certificates. | 22 // CertVerifier represents a service for verifying certificates. |
| 22 // | 23 // |
| 23 // CertVerifiers can handle multiple requests at a time. | 24 // CertVerifiers can handle multiple requests at a time. |
| 24 class NET_EXPORT CertVerifier { | 25 class NET_EXPORT CertVerifier { |
| 25 public: | 26 public: |
| 26 class Request { | 27 class Request { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 // Note: If VERIFY_CERT_IO_ENABLE is not also supplied, certificates | 69 // Note: If VERIFY_CERT_IO_ENABLE is not also supplied, certificates |
| 69 // that chain to local trust anchors will likely fail - for example, due to | 70 // that chain to local trust anchors will likely fail - for example, due to |
| 70 // lacking fresh cached revocation issue (Windows) or because OCSP stapling | 71 // lacking fresh cached revocation issue (Windows) or because OCSP stapling |
| 71 // can only provide information for the leaf, and not for any | 72 // can only provide information for the leaf, and not for any |
| 72 // intermediates. | 73 // intermediates. |
| 73 VERIFY_REV_CHECKING_REQUIRED_LOCAL_ANCHORS = 1 << 4, | 74 VERIFY_REV_CHECKING_REQUIRED_LOCAL_ANCHORS = 1 << 4, |
| 74 }; | 75 }; |
| 75 | 76 |
| 76 // When the verifier is destroyed, all certificate verification requests are | 77 // When the verifier is destroyed, all certificate verification requests are |
| 77 // canceled, and their completion callbacks will not be called. | 78 // canceled, and their completion callbacks will not be called. |
| 78 virtual ~CertVerifier() {} | 79 virtual ~CertVerifier(); |
| 79 | 80 |
| 80 // Verifies the given certificate against the given hostname as an SSL server. | 81 // Verifies the given certificate against the given hostname as an SSL server. |
| 81 // Returns OK if successful or an error code upon failure. | 82 // Returns OK if successful or an error code upon failure. |
| 82 // | 83 // |
| 83 // The |*verify_result| structure, including the |verify_result->cert_status| | 84 // The |*verify_result| structure, including the |verify_result->cert_status| |
| 84 // bitmask, is always filled out regardless of the return value. If the | 85 // bitmask, is always filled out regardless of the return value. If the |
| 85 // certificate has multiple errors, the corresponding status flags are set in | 86 // certificate has multiple errors, the corresponding status flags are set in |
| 86 // |verify_result->cert_status|, and the error code for the most serious | 87 // |verify_result->cert_status|, and the error code for the most serious |
| 87 // error is returned. | 88 // error is returned. |
| 88 // | 89 // |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 const CompletionCallback& callback, | 123 const CompletionCallback& callback, |
| 123 scoped_ptr<Request>* out_req, | 124 scoped_ptr<Request>* out_req, |
| 124 const BoundNetLog& net_log) = 0; | 125 const BoundNetLog& net_log) = 0; |
| 125 | 126 |
| 126 // Returns true if this CertVerifier supports stapled OCSP responses. | 127 // Returns true if this CertVerifier supports stapled OCSP responses. |
| 127 virtual bool SupportsOCSPStapling(); | 128 virtual bool SupportsOCSPStapling(); |
| 128 | 129 |
| 129 // Creates a CertVerifier implementation that verifies certificates using | 130 // Creates a CertVerifier implementation that verifies certificates using |
| 130 // the preferred underlying cryptographic libraries. | 131 // the preferred underlying cryptographic libraries. |
| 131 static CertVerifier* CreateDefault(); | 132 static CertVerifier* CreateDefault(); |
| 133 | |
| 134 static CertVerifier* CreateWithVerifyProc(CertVerifyProc* cert_verify_proc); | |
|
Ryan Sleevi
2015/07/09 19:35:28
Why the need to expose this interface?
I really d
estark
2015/07/09 20:14:24
So I'm trying to use this instead of places where
| |
| 135 }; | |
| 136 | |
| 137 // CertVerifierFactory creates CertVerifiers. There is a single global | |
| 138 // CertVerifierFactory, which allows tests to inject mock verifiers. | |
| 139 class NET_EXPORT CertVerifierFactory { | |
|
Ryan Sleevi
2015/07/09 19:35:27
This is a design I intentionally wanted to avoid a
estark
2015/07/09 20:11:50
Email thread with you me and Matt titled "MockCert
| |
| 140 public: | |
| 141 CertVerifierFactory(); | |
| 142 virtual ~CertVerifierFactory(); | |
| 143 | |
| 144 // Creates a new CertVerifier which will use the given | |
| 145 // |cert_verify_proc|. Ownership of the returned CertVerifier is | |
| 146 // assumed by the caller. The CertVerifier will own the given | |
| 147 // |cert_verify_proc|. | |
| 148 virtual CertVerifier* CreateCertVerifier(CertVerifyProc* cert_verify_proc); | |
| 149 | |
| 150 // Gets and sets the the global CertVerifierFactory. | |
| 151 static CertVerifierFactory* GetCertVerifierFactory(); | |
| 152 static void SetCertVerifierFactory(CertVerifierFactory* factory); | |
| 153 | |
| 154 private: | |
| 155 static CertVerifierFactory* cert_verifier_factory_; | |
|
Ryan Sleevi
2015/07/09 19:40:26
There's (generally) no need for such private stati
| |
| 156 | |
| 157 DISALLOW_COPY_AND_ASSIGN(CertVerifierFactory); | |
| 132 }; | 158 }; |
| 133 | 159 |
| 134 } // namespace net | 160 } // namespace net |
| 135 | 161 |
| 136 #endif // NET_CERT_CERT_VERIFIER_H_ | 162 #endif // NET_CERT_CERT_VERIFIER_H_ |
| OLD | NEW |