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

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

Issue 1357773002: WKWebView: Implemented recoverable SSL interstitials. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lock_coloring
Patch Set: Addressed Joel's review comments Created 5 years, 2 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_CRW_CERT_VERIFICATION_CONTROLLER_H_ 5 #ifndef IOS_WEB_NET_CRW_CERT_VERIFICATION_CONTROLLER_H_
6 #define IOS_WEB_NET_CRW_CERT_VERIFICATION_CONTROLLER_H_ 6 #define IOS_WEB_NET_CRW_CERT_VERIFICATION_CONTROLLER_H_
7 7
8 #import <Foundation/Foundation.h> 8 #import <Foundation/Foundation.h>
9 9
10 #include "base/mac/scoped_cftyperef.h" 10 #include "base/mac/scoped_cftyperef.h"
11 #import "base/memory/ref_counted.h" 11 #import "base/memory/ref_counted.h"
12 #include "ios/web/public/security_style.h" 12 #include "ios/web/public/security_style.h"
13 #include "net/cert/cert_status_flags.h" 13 #include "net/cert/cert_status_flags.h"
14 14
15 namespace net { 15 namespace net {
16 class X509Certificate; 16 class X509Certificate;
17 } 17 }
18 18
19 namespace web { 19 namespace web {
20 20
21 class BrowserState; 21 class BrowserState;
22 22
23 // Accept policy for valid or invalid SSL cert. 23 // Accept policy for valid or invalid SSL cert.
24 typedef NS_ENUM(NSInteger, CertAcceptPolicy) { 24 typedef NS_ENUM(NSInteger, CertAcceptPolicy) {
25 // Cert status can't be determined due to an error. Caller should not proceed 25 // Cert status can't be determined due to an error. Caller should reject the
26 // with the load, but show net error page instead. 26 // load and show net error page.
27 CERT_ACCEPT_POLICY_NON_RECOVERABLE_ERROR = 0, 27 CERT_ACCEPT_POLICY_NON_RECOVERABLE_ERROR = 0,
28 // Cert is not valid. Caller may present SSL warning and ask user if they 28 // Cert is not valid. Caller may present SSL warning and ask user if they
29 // want to proceed with the load. 29 // want to proceed or reject the load.
30 CERT_ACCEPT_POLICY_RECOVERABLE_ERROR, 30 CERT_ACCEPT_POLICY_RECOVERABLE_ERROR_UNDECIDED_BY_USER,
31 // Cert is not valid. However caller should proceed with the load because
32 // user has decided to proceed with this invalid cert.
33 CERT_ACCEPT_POLICY_RECOVERABLE_ERROR_ACCEPTED_BY_USER,
31 // Cert is valid. Caller should proceed with the load. 34 // Cert is valid. Caller should proceed with the load.
32 CERT_ACCEPT_POLICY_ALLOW, 35 CERT_ACCEPT_POLICY_ALLOW,
33 }; 36 };
34 37
35 // Completion handler called by decidePolicyForCert:host:completionHandler:. 38 // Completion handler called by decideLoadPolicyForTrust:host:completionHandler.
36 typedef void (^PolicyDecisionHandler)(web::CertAcceptPolicy, net::CertStatus); 39 typedef void (^PolicyDecisionHandler)(web::CertAcceptPolicy, net::CertStatus);
37 // Completion handler called by querySSLStatusForTrust:host:completionHandler:. 40 // Completion handler called by querySSLStatusForTrust:host:completionHandler:.
38 typedef void (^StatusQueryHandler)(web::SecurityStyle, net::CertStatus); 41 typedef void (^StatusQueryHandler)(web::SecurityStyle, net::CertStatus);
39 42
40 } // namespace web 43 } // namespace web
41 44
42 // Provides various cert verification API that can be used for blocking requests 45 // Provides various cert verification API that can be used for blocking requests
43 // with bad SSL cert, presenting SSL interstitials and determining SSL status 46 // with bad SSL cert, presenting SSL interstitials and determining SSL status
44 // for Navigation Items. Must be used on UI thread. 47 // for Navigation Items. Must be used on UI thread.
45 @interface CRWCertVerificationController : NSObject 48 @interface CRWCertVerificationController : NSObject
46 49
47 - (instancetype)init NS_UNAVAILABLE; 50 - (instancetype)init NS_UNAVAILABLE;
48 51
49 // Initializes CRWCertVerificationController with the given |browserState| which 52 // Initializes CRWCertVerificationController with the given |browserState| which
50 // cannot be null and must outlive CRWCertVerificationController. 53 // cannot be null and must outlive CRWCertVerificationController.
51 - (instancetype)initWithBrowserState:(web::BrowserState*)browserState 54 - (instancetype)initWithBrowserState:(web::BrowserState*)browserState
52 NS_DESIGNATED_INITIALIZER; 55 NS_DESIGNATED_INITIALIZER;
53 56
54 // TODO(eugenebut): add API for: 57 // Decides the policy for the given |trust| and for the given |host| and calls
55 // - accepting bad SSL cert using CertPolicyCache
56
57 // Decides the policy for the given |cert| for the given |host| and calls
58 // |completionHandler| on completion. |host| should be in ASCII compatible form 58 // |completionHandler| on completion. |host| should be in ASCII compatible form
59 // (e.g. for "http://名がドメイン.com", it should be "xn--v8jxj3d1dzdz08w.com"). 59 // (e.g. for "http://名がドメイン.com", it should be "xn--v8jxj3d1dzdz08w.com").
60 // |completionHandler| cannot be null and will be called asynchronously on the 60 // |completionHandler| cannot be null and will be called asynchronously on the
61 // UI thread. 61 // UI thread.
Ryan Sleevi 2015/10/19 23:56:21 Include a forward reference to allowCert here //
Eugene But (OOO till 7-30) 2015/10/21 04:01:02 Done.
62 - (void)decidePolicyForCert:(const scoped_refptr<net::X509Certificate>&)cert 62 - (void)decideLoadPolicyForTrust:(base::ScopedCFTypeRef<SecTrustRef>)trust
63 host:(NSString*)host 63 host:(NSString*)host
64 completionHandler:(web::PolicyDecisionHandler)completionHandler; 64 completionHandler:(web::PolicyDecisionHandler)completionHandler;
65 65
66 // Asynchronously provides web::SecurityStyle and net::CertStatus for the given 66 // Asynchronously provides web::SecurityStyle and net::CertStatus for the given
67 // |serverTrust| and |host|. |host| should be in ASCII compatible form. 67 // |trust| and |host|. |host| should be in ASCII compatible form.
68 // Note: The web::SecurityStyle determines whether the certificate is trusted. 68 // Note: The web::SecurityStyle determines whether the certificate is trusted.
69 // It is possible for an untrusted certificate to return a net::CertStatus with 69 // It is possible for an untrusted certificate to return a net::CertStatus with
70 // no errors if the cause could not be determined. Callers must handle this case 70 // no errors if the cause could not be determined. Callers must handle this case
71 // gracefully. 71 // gracefully.
72 - (void)querySSLStatusForTrust:(base::ScopedCFTypeRef<SecTrustRef>)serverTrust 72 - (void)querySSLStatusForTrust:(base::ScopedCFTypeRef<SecTrustRef>)trust
73 host:(NSString*)host 73 host:(NSString*)host
74 completionHandler:(web::StatusQueryHandler)completionHandler; 74 completionHandler:(web::StatusQueryHandler)completionHandler;
75 75
76 // Records that |cert| is permitted to be used for |host| in the future.
77 // |host| should be in ASCII compatible form. Next time when
78 // |decideLoadPolicyForTrust:| is called for the same server cert it will return
79 // CERT_ACCEPT_POLICY_RECOVERABLE_ERROR_ACCEPTED_BY_USER if cert error is
80 // recoverable.
Ryan Sleevi 2015/10/19 23:56:21 This comment needs rewording // Records that |cer
Eugene But (OOO till 7-30) 2015/10/21 04:01:02 Done.
81 - (void)allowCert:(scoped_refptr<net::X509Certificate>)cert
82 forHost:(NSString*)host
83 status:(net::CertStatus)status;
Ryan Sleevi 2015/10/19 23:56:21 Does this mean you can only ignore a single error?
Eugene But (OOO till 7-30) 2015/10/21 04:01:02 This will do whatever web::CertificatePolicyCache
84
76 // Cancels all pending verification requests. Completion handlers will not be 85 // Cancels all pending verification requests. Completion handlers will not be
77 // called after |shutDown| call. Must always be called before object's 86 // called after |shutDown| call. Must always be called before object's
78 // deallocation. 87 // deallocation.
79 - (void)shutDown; 88 - (void)shutDown;
80 89
81 @end 90 @end
82 91
83 #endif // IOS_WEB_NET_CRW_CERT_VERIFICATION_CONTROLLER_H_ 92 #endif // IOS_WEB_NET_CRW_CERT_VERIFICATION_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698