| 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_SINGLE_REQUEST_CERT_VERIFIER_H_ | 5 #ifndef NET_CERT_SINGLE_REQUEST_CERT_VERIFIER_H_ |
| 6 #define NET_CERT_SINGLE_REQUEST_CERT_VERIFIER_H_ | 6 #define NET_CERT_SINGLE_REQUEST_CERT_VERIFIER_H_ |
| 7 | 7 |
| 8 #include "net/cert/cert_verifier.h" | 8 #include "net/cert/cert_verifier.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| 11 | 11 |
| 12 // This class represents the task of verifying a certificate. It wraps | 12 // This class represents the task of verifying a certificate. It wraps |
| 13 // CertVerifier to verify only a single certificate at a time and cancels this | 13 // CertVerifier to verify only a single certificate at a time and cancels this |
| 14 // request when going out of scope. | 14 // request when going out of scope. |
| 15 class SingleRequestCertVerifier { | 15 class SingleRequestCertVerifier { |
| 16 public: | 16 public: |
| 17 // |cert_verifier| must remain valid for the lifetime of |this|. | 17 // |cert_verifier| must remain valid for the lifetime of |this|. |
| 18 explicit SingleRequestCertVerifier(CertVerifier* cert_verifier); | 18 explicit SingleRequestCertVerifier(CertVerifier* cert_verifier); |
| 19 | 19 |
| 20 // If a completion callback is pending when the verifier is destroyed, the | 20 // If a completion callback is pending when the verifier is destroyed, the |
| 21 // certificate verification is canceled, and the completion callback will | 21 // certificate verification is canceled, and the completion callback will |
| 22 // not be called. | 22 // not be called. |
| 23 ~SingleRequestCertVerifier(); | 23 ~SingleRequestCertVerifier(); |
| 24 | 24 |
| 25 // Verifies the given certificate, filling out the |verify_result| object | 25 // Verifies the given certificate, filling out the |verify_result| object |
| 26 // upon success. See CertVerifier::Verify() for details. | 26 // upon success. See CertVerifier::Verify() for details. |
| 27 int Verify(X509Certificate* cert, | 27 int Verify(X509Certificate* cert, |
| 28 const std::string& hostname, | 28 const std::string& hostname, |
| 29 const std::string& ocsp_response, |
| 29 int flags, | 30 int flags, |
| 30 CRLSet* crl_set, | 31 CRLSet* crl_set, |
| 31 CertVerifyResult* verify_result, | 32 CertVerifyResult* verify_result, |
| 32 const CompletionCallback& callback, | 33 const CompletionCallback& callback, |
| 33 const BoundNetLog& net_log); | 34 const BoundNetLog& net_log); |
| 34 | 35 |
| 35 private: | 36 private: |
| 36 // Callback for when the request to |cert_verifier_| completes, so we | 37 // Callback for when the request to |cert_verifier_| completes, so we |
| 37 // dispatch to the user's callback. | 38 // dispatch to the user's callback. |
| 38 void OnVerifyCompletion(int result); | 39 void OnVerifyCompletion(int result); |
| 39 | 40 |
| 40 // The actual certificate verifier that will handle the request. | 41 // The actual certificate verifier that will handle the request. |
| 41 CertVerifier* const cert_verifier_; | 42 CertVerifier* const cert_verifier_; |
| 42 | 43 |
| 43 // The current request (if any). | 44 // The current request (if any). |
| 44 CertVerifier::RequestHandle cur_request_; | 45 CertVerifier::RequestHandle cur_request_; |
| 45 CompletionCallback cur_request_callback_; | 46 CompletionCallback cur_request_callback_; |
| 46 | 47 |
| 47 DISALLOW_COPY_AND_ASSIGN(SingleRequestCertVerifier); | 48 DISALLOW_COPY_AND_ASSIGN(SingleRequestCertVerifier); |
| 48 }; | 49 }; |
| 49 | 50 |
| 50 } // namespace net | 51 } // namespace net |
| 51 | 52 |
| 52 #endif // NET_CERT_SINGLE_REQUEST_CERT_VERIFIER_H_ | 53 #endif // NET_CERT_SINGLE_REQUEST_CERT_VERIFIER_H_ |
| OLD | NEW |