Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: ios/web/net/cert_verifier_block_adapter.h

Issue 1230033005: WKWebView: Added cert verification API to web controller. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor cleanup. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 IOS_WEB_NET_CERT_VERIFIER_BLOCK_ADAPTER_H_ 5 #ifndef IOS_WEB_NET_CERT_VERIFIER_BLOCK_ADAPTER_H_
6 #define IOS_WEB_NET_CERT_VERIFIER_BLOCK_ADAPTER_H_ 6 #define IOS_WEB_NET_CERT_VERIFIER_BLOCK_ADAPTER_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/scoped_vector.h"
9 #include "net/cert/cert_verifier.h" 10 #include "net/cert/cert_verifier.h"
11 #include "net/cert/cert_verify_result.h"
10 #include "net/log/net_log.h" 12 #include "net/log/net_log.h"
11 13
12 namespace net { 14 namespace net {
13 15
14 class CertVerifyResult;
15 class CRLSet; 16 class CRLSet;
16 class X509Certificate; 17 class X509Certificate;
17 18
18 // Provides block-based interface for net::CertVerifier. 19 // Provides block-based interface for net::CertVerifier.
19 class CertVerifierBlockAdapter { 20 class CertVerifierBlockAdapter {
20 public: 21 public:
21 CertVerifierBlockAdapter(); 22 // Constructs adapter with given |CertVerifier| and |NetLog| which can not be
22 // Constructs adapter with given |CertVerifier| which can not be null. 23 // null. CertVerifierBlockAdapter does NOT take ownership over |cert_verifier|
23 CertVerifierBlockAdapter(scoped_ptr<CertVerifier> cert_verifier); 24 // and |net_log|.
25 CertVerifierBlockAdapter(CertVerifier* cert_verifier, NetLog* net_log);
24 26
25 // When the verifier is destroyed, all certificate verification requests are 27 // When the verifier is destroyed, all certificate verification requests are
26 // canceled, and their completion handlers will not be called. 28 // canceled, and their completion handlers will not be called.
27 ~CertVerifierBlockAdapter(); 29 ~CertVerifierBlockAdapter();
28 30
29 // Encapsulates verification parms. |cert| and |hostname| are mandatory, the 31 // Encapsulates verification params. |cert| and |hostname| are mandatory, the
30 // other params are optional. If either of mandatory arguments is null or 32 // other params are optional. If either of mandatory arguments is null or
31 // empty then verification |CompletionHandler| will be called with 33 // empty then verification |CompletionHandler| will be called with
32 // ERR_INVALID_ARGUMENT status. 34 // ERR_INVALID_ARGUMENT status.
33 struct Params { 35 struct Params {
34 // Constructs Params from X509 cert and hostname, which are mandatory for 36 // Constructs Params from X509 cert and hostname, which are mandatory for
35 // verification. 37 // verification.
36 Params(scoped_refptr<net::X509Certificate> cert, 38 Params(scoped_refptr<net::X509Certificate> cert,
37 const std::string& hostname); 39 const std::string& hostname);
38 ~Params(); 40 ~Params();
39 41
40 // Certificate to verify, can not be null. 42 // Certificate to verify, can not be null.
41 scoped_refptr<net::X509Certificate> cert; 43 scoped_refptr<net::X509Certificate> cert;
42 44
43 // Hostname as an SSL server, can not be empty. 45 // Hostname as an SSL server, can not be empty.
44 std::string hostname; 46 std::string hostname;
45 47
46 // If non-empty, is a stapled OCSP response to use. 48 // If non-empty, is a stapled OCSP response to use.
47 std::string ocsp_response; 49 std::string ocsp_response;
48 50
49 // Bitwise OR of CertVerifier::VerifyFlags. 51 // Bitwise OR of CertVerifier::VerifyFlags.
50 CertVerifier::VerifyFlags flags; 52 int flags;
51 53
52 // An optional CRLSet structure which can be used to avoid revocation checks 54 // An optional CRLSet structure which can be used to avoid revocation checks
53 // over the network. 55 // over the network.
54 scoped_refptr<CRLSet> crl_set; 56 scoped_refptr<CRLSet> crl_set;
55 }; 57 };
56 58
57 // Type of verification completion block. On success CertVerifyResult is not 59 // Type of verification completion block. On success status is OK, otherwise
58 // null and status is OK, otherwise CertVerifyResult is null and status is a 60 // status is a net error code and CertVerifyResult is not a valid object.
59 // net error code. 61 typedef void (^CompletionHandler)(CertVerifyResult, int status);
60 typedef void (^CompletionHandler)(scoped_ptr<CertVerifyResult>, int status);
61 62
62 // Verifies certificate with given |params|. |completion_handler| must not be 63 // Verifies certificate with given |params|. |completion_handler| must not be
63 // null and call be called either syncronously (in the same runloop) or 64 // null and call be called either synchronously (in the same runloop) or
64 // asyncronously. 65 // asynchronously.
Ryan Sleevi 2015/08/07 21:52:12 Does this API requirement match SecTrust's? If th
Eugene But (OOO till 7-30) 2015/08/12 22:00:38 SecTrustEvaluateAsync always calls block asynchron
65 void Verify(const Params& params, CompletionHandler completion_handler); 66 void Verify(const Params& params, CompletionHandler completion_handler);
66 67
67 private: 68 private:
68 // Underlying CertVerifier. 69 // Pending verification requests. Request must be alive until verification is
69 scoped_ptr<CertVerifier> cert_verifier_; 70 // completed, otherwise verification operation will be cancelled.
70 // Net Log required by CertVerifier. 71 ScopedVector<CertVerifier::Request> pending_requests_;
72 // Underlying unowned CertVerifier.
73 CertVerifier* cert_verifier_;
74 // BoundNetLog required by CertVerifier.
71 BoundNetLog net_log_; 75 BoundNetLog net_log_;
72 }; 76 };
73 77
74 } // net 78 } // net
75 79
76 #endif // IOS_WEB_NET_CERT_VERIFIER_BLOCK_ADAPTER_H_ 80 #endif // IOS_WEB_NET_CERT_VERIFIER_BLOCK_ADAPTER_H_
OLDNEW
« no previous file with comments | « no previous file | ios/web/net/cert_verifier_block_adapter.cc » ('j') | ios/web/net/cert_verifier_block_adapter.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698