| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 CHROME_BROWSER_CHROMEOS_POLICY_POLICY_CERT_VERIFIER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_POLICY_CERT_VERIFIER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_POLICY_CERT_VERIFIER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_POLICY_CERT_VERIFIER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "net/base/completion_callback.h" | 15 #include "net/base/completion_callback.h" |
| 16 #include "net/cert/cert_trust_anchor_provider.h" | |
| 17 #include "net/cert/cert_verifier.h" | 16 #include "net/cert/cert_verifier.h" |
| 18 | 17 |
| 19 namespace net { | 18 namespace net { |
| 20 class CertVerifyProc; | 19 class CertVerifyProc; |
| 21 class CertVerifyResult; | 20 class CertVerifyResult; |
| 22 class X509Certificate; | 21 class X509Certificate; |
| 23 typedef std::vector<scoped_refptr<X509Certificate> > CertificateList; | 22 typedef std::vector<scoped_refptr<X509Certificate> > CertificateList; |
| 24 } | 23 } |
| 25 | 24 |
| 26 namespace policy { | 25 namespace policy { |
| 27 | 26 |
| 28 // Wraps a MultiThreadedCertVerifier to make it use the additional trust anchors | 27 // Wraps a MultiThreadedCertVerifier to make it use the additional trust anchors |
| 29 // configured by the ONC user policy. | 28 // configured by the ONC user policy. |
| 30 class PolicyCertVerifier : public net::CertVerifier, | 29 class PolicyCertVerifier : public net::CertVerifier { |
| 31 public net::CertTrustAnchorProvider { | |
| 32 public: | 30 public: |
| 33 // Except for tests, PolicyCertVerifier should only be created by | 31 // Except for tests, PolicyCertVerifier should only be created by |
| 34 // PolicyCertService, which is the counterpart of this class on the UI thread. | 32 // PolicyCertService, which is the counterpart of this class on the UI thread. |
| 35 // Except of the constructor, all methods and the destructor must be called on | 33 // Except of the constructor, all methods and the destructor must be called on |
| 36 // the IO thread. Calls |anchor_used_callback| on the IO thread everytime a | 34 // the IO thread. Calls |anchor_used_callback| on the IO thread everytime a |
| 37 // certificate from the additional trust anchors (set with SetTrustAnchors) is | 35 // certificate from the additional trust anchors (set with SetTrustAnchors) is |
| 38 // used. | 36 // used. |
| 39 explicit PolicyCertVerifier(const base::Closure& anchor_used_callback); | 37 explicit PolicyCertVerifier(const base::Closure& anchor_used_callback); |
| 40 ~PolicyCertVerifier() override; | 38 ~PolicyCertVerifier() override; |
| 41 | 39 |
| 42 void InitializeOnIOThread( | 40 void InitializeOnIOThread( |
| 43 const scoped_refptr<net::CertVerifyProc>& verify_proc); | 41 const scoped_refptr<net::CertVerifyProc>& verify_proc); |
| 44 | 42 |
| 45 // Sets the additional trust anchors. | 43 // Sets the additional trust anchors. |
| 46 void SetTrustAnchors(const net::CertificateList& trust_anchors); | 44 void SetTrustAnchors(const net::CertificateList& trust_anchors); |
| 47 | 45 |
| 48 // CertVerifier: | 46 // CertVerifier: |
| 49 // Note: |callback| can be null. | 47 // Note: |callback| can be null. |
| 50 int Verify(const RequestParams& params, | 48 int Verify(const RequestParams& params, |
| 51 net::CRLSet* crl_set, | 49 net::CRLSet* crl_set, |
| 52 net::CertVerifyResult* verify_result, | 50 net::CertVerifyResult* verify_result, |
| 53 const net::CompletionCallback& callback, | 51 const net::CompletionCallback& callback, |
| 54 std::unique_ptr<Request>* out_req, | 52 std::unique_ptr<Request>* out_req, |
| 55 const net::BoundNetLog& net_log) override; | 53 const net::BoundNetLog& net_log) override; |
| 56 | 54 |
| 57 bool SupportsOCSPStapling() override; | 55 bool SupportsOCSPStapling() override; |
| 58 | 56 |
| 59 // CertTrustAnchorProvider: | |
| 60 const net::CertificateList& GetAdditionalTrustAnchors() override; | |
| 61 | |
| 62 private: | 57 private: |
| 63 net::CertificateList trust_anchors_; | 58 net::CertificateList trust_anchors_; |
| 64 base::Closure anchor_used_callback_; | 59 base::Closure anchor_used_callback_; |
| 65 std::unique_ptr<CertVerifier> delegate_; | 60 std::unique_ptr<CertVerifier> delegate_; |
| 66 | 61 |
| 67 DISALLOW_COPY_AND_ASSIGN(PolicyCertVerifier); | 62 DISALLOW_COPY_AND_ASSIGN(PolicyCertVerifier); |
| 68 }; | 63 }; |
| 69 | 64 |
| 70 } // namespace policy | 65 } // namespace policy |
| 71 | 66 |
| 72 #endif // CHROME_BROWSER_CHROMEOS_POLICY_POLICY_CERT_VERIFIER_H_ | 67 #endif // CHROME_BROWSER_CHROMEOS_POLICY_POLICY_CERT_VERIFIER_H_ |
| OLD | NEW |