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