OLD | NEW |
---|---|
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 #import "base/memory/ref_counted.h" | 10 #import "base/memory/ref_counted.h" |
11 #include "ios/web/public/security_style.h" | |
11 #include "net/cert/cert_status_flags.h" | 12 #include "net/cert/cert_status_flags.h" |
12 | 13 |
13 namespace net { | 14 namespace net { |
14 class X509Certificate; | 15 class X509Certificate; |
15 } | 16 } |
16 | 17 |
17 namespace web { | 18 namespace web { |
18 | 19 |
19 class BrowserState; | 20 class BrowserState; |
20 | 21 |
21 // Accept policy for valid or invalid SSL cert. | 22 // Accept policy for valid or invalid SSL cert. |
22 typedef NS_ENUM(NSInteger, CertAcceptPolicy) { | 23 typedef NS_ENUM(NSInteger, CertAcceptPolicy) { |
23 // Cert status can't be determined due to an error. Caller should not proceed | 24 // Cert status can't be determined due to an error. Caller should not proceed |
24 // with the load, but show net error page instead. | 25 // with the load, but show net error page instead. |
25 CERT_ACCEPT_POLICY_NON_RECOVERABLE_ERROR = 0, | 26 CERT_ACCEPT_POLICY_NON_RECOVERABLE_ERROR = 0, |
26 // Cert is not valid. Caller may present SSL warning and ask user if they | 27 // Cert is not valid. Caller may present SSL warning and ask user if they |
27 // want to proceed with the load. | 28 // want to proceed with the load. |
28 CERT_ACCEPT_POLICY_RECOVERABLE_ERROR, | 29 CERT_ACCEPT_POLICY_RECOVERABLE_ERROR, |
29 // Cert is valid. Caller should proceed with the load. | 30 // Cert is valid. Caller should proceed with the load. |
30 CERT_ACCEPT_POLICY_ALLOW, | 31 CERT_ACCEPT_POLICY_ALLOW, |
31 }; | 32 }; |
32 | 33 |
33 // Completion handler called by decidePolicyForCert:host:completionHandler:. | 34 // Completion handler called by decidePolicyForCert:host:completionHandler:. |
34 typedef void (^PolicyDecisionHandler)(web::CertAcceptPolicy, net::CertStatus); | 35 typedef void (^PolicyDecisionHandler)(web::CertAcceptPolicy, net::CertStatus); |
36 // Completion handler called by decidePolicyForCert:host:completionHandler:. | |
37 typedef void (^StatusQueryHandler)(web::SecurityStyle, net::CertStatus); | |
35 | 38 |
36 } // namespace web | 39 } // namespace web |
37 | 40 |
38 // Provides various cert verification API that can be used for blocking requests | 41 // Provides various cert verification API that can be used for blocking requests |
39 // with bad SSL cert, presenting SSL interstitials and determining SSL status | 42 // with bad SSL cert, presenting SSL interstitials and determining SSL status |
40 // for Navigation Items. Must be used on UI thread. | 43 // for Navigation Items. Must be used on UI thread. |
41 @interface CRWCertVerificationController : NSObject | 44 @interface CRWCertVerificationController : NSObject |
42 | 45 |
43 - (instancetype)init NS_UNAVAILABLE; | 46 - (instancetype)init NS_UNAVAILABLE; |
44 | 47 |
45 // Initializes CRWCertVerificationController with the given |browserState| which | 48 // Initializes CRWCertVerificationController with the given |browserState| which |
46 // cannot be null and must outlive CRWCertVerificationController. | 49 // cannot be null and must outlive CRWCertVerificationController. |
47 - (instancetype)initWithBrowserState:(web::BrowserState*)browserState | 50 - (instancetype)initWithBrowserState:(web::BrowserState*)browserState |
48 NS_DESIGNATED_INITIALIZER; | 51 NS_DESIGNATED_INITIALIZER; |
49 | 52 |
50 // TODO(eugenebut): add API for: | 53 // TODO(eugenebut): add API for: |
51 // - accepting bad SSL cert using CertPolicyCache | 54 // - accepting bad SSL cert using CertPolicyCache |
52 // - querying SSL cert status for Navigation Item | |
53 | 55 |
54 // Decides the policy for the given |cert| for the given |host| and calls | 56 // Decides the policy for the given |cert| for the given |host| and calls |
55 // |completionHandler| on completion. |completionHandler| cannot be null and | 57 // |completionHandler| on completion. |completionHandler| cannot be null and |
56 // will be called synchronously or asynchronously on UI thread. | 58 // will be called synchronously or asynchronously on UI thread. |
57 - (void)decidePolicyForCert:(const scoped_refptr<net::X509Certificate>&)cert | 59 - (void)decidePolicyForCert:(const scoped_refptr<net::X509Certificate>&)cert |
58 host:(NSString*)host | 60 host:(NSString*)host |
59 completionHandler:(web::PolicyDecisionHandler)handler; | 61 completionHandler:(web::PolicyDecisionHandler)completionHandler; |
62 | |
63 // Asynchronously returns web::SecurityStyle and net::CertStatus for the given | |
64 // |certificateChain| (an NSArray of SecSertificateRef objects) and |host|. | |
Ryan Sleevi
2015/09/19 12:45:37
Document what form host is
It in URL form? DNS fo
Eugene But (OOO till 7-30)
2015/09/21 17:23:39
If you load "https://[::1]" then host will be "::1
| |
65 // |certificateChain| cannot be null or empty. | |
66 - (void)querySSLStatusForCertChain:(NSArray*)certChain | |
67 host:(NSString*)host | |
68 completionHandler:(web::StatusQueryHandler)completionHandler; | |
60 | 69 |
61 // Cancels all pending verification requests. Completion handlers will not be | 70 // Cancels all pending verification requests. Completion handlers will not be |
62 // called after |shutDown| call. Must always be called before object's | 71 // called after |shutDown| call. Must always be called before object's |
63 // deallocation. | 72 // deallocation. |
64 - (void)shutDown; | 73 - (void)shutDown; |
65 | 74 |
66 @end | 75 @end |
67 | 76 |
68 #endif // IOS_WEB_NET_CRW_CERT_VERIFICATION_CONTROLLER_H_ | 77 #endif // IOS_WEB_NET_CRW_CERT_VERIFICATION_CONTROLLER_H_ |
OLD | NEW |