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

Unified Diff: ios/web/net/crw_cert_verification_controller.mm

Issue 1322193003: WKWebView(iOS9): correctly update SSL status for current navigation item (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@reland_cert_verification
Patch Set: Corrected comment Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: ios/web/net/crw_cert_verification_controller.mm
diff --git a/ios/web/net/crw_cert_verification_controller.mm b/ios/web/net/crw_cert_verification_controller.mm
index b8dba8fa106811aa2c53aeffbe5539587ea8f301..8e169cb42e231d83f9115992dfe624f0b9372915 100644
--- a/ios/web/net/crw_cert_verification_controller.mm
+++ b/ios/web/net/crw_cert_verification_controller.mm
@@ -11,6 +11,7 @@
#include "ios/web/net/cert_verifier_block_adapter.h"
#include "ios/web/public/browser_state.h"
#include "ios/web/public/web_thread.h"
+#import "ios/web/web_state/wk_web_view_security_util.h"
#include "net/cert/cert_verify_result.h"
#include "net/ssl/ssl_config_service.h"
#include "net/url_request/url_request_context.h"
@@ -106,16 +107,16 @@ class BlockHolder : public base::RefCountedThreadSafe<BlockHolder<T>> {
- (void)decidePolicyForCert:(const scoped_refptr<net::X509Certificate>&)cert
host:(NSString*)host
- completionHandler:(web::PolicyDecisionHandler)handler {
+ completionHandler:(web::PolicyDecisionHandler)completionHandler {
DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::UI);
// completionHandler of |verifyCert:forHost:completionHandler:| is called on
// IO thread and then bounces back to UI thread. As a result all objects
// captured by completionHandler may be released on either UI or IO thread.
- // Since |handler| can potentially capture multiple thread unsafe objects
- // (like Web Controller) |handler| itself should never be released on
- // background thread and |BlockHolder| ensures that.
+ // Since |completionHandler| can potentially capture multiple thread unsafe
+ // objects (like Web Controller) |completionHandler| itself should never be
+ // released on background thread and |BlockHolder| ensures that.
__block scoped_refptr<BlockHolder<web::PolicyDecisionHandler>> handlerHolder(
- new BlockHolder<web::PolicyDecisionHandler>(handler));
+ new BlockHolder<web::PolicyDecisionHandler>(completionHandler));
[self verifyCert:cert
forHost:host
completionHandler:^(net::CertVerifyResult result, int error) {
@@ -135,6 +136,38 @@ class BlockHolder : public base::RefCountedThreadSafe<BlockHolder<T>> {
}];
}
+- (void)querySSLStatusForCertChain:(NSArray*)certChain
+ host:(NSString*)host
+ completionHandler:(web::StatusQueryHandler)completionHandler {
+ DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::UI);
+ DCHECK(certChain.count);
+
+ // Completion handler of |verifyCert:forHost:completionHandler:| will be
+ // deallocated on IO thread. |completionHandler| itself should never be
+ // released on background thread and |BlockHolder| ensures that.
+ __block scoped_refptr<BlockHolder<web::StatusQueryHandler>> handlerHolder(
+ new BlockHolder<web::StatusQueryHandler>(completionHandler));
+ scoped_refptr<net::X509Certificate> cert(web::CreateCertFromChain(certChain));
+ // Knowing net::CertStatus is necessry even for valid certs in order to
+ // support SHA-1 deprecation.
+ [self verifyCert:cert
+ forHost:host
+ completionHandler:^(net::CertVerifyResult certVerifierResult, int) {
+ base::ScopedCFTypeRef<SecTrustRef> trust(
+ web::CreateServerTrustFromChain(certChain, host));
+
+ SecTrustResultType trustResult = kSecTrustResultInvalid;
+ if (errSecSuccess != SecTrustEvaluate(trust.get(), &trustResult)) {
stuartmorgan 2015/09/10 22:26:18 Chromium style prefers the 'variable == constant'
Eugene But (OOO till 7-30) 2015/09/14 23:20:30 Acknowledged.
+ trustResult = kSecTrustResultInvalid;
stuartmorgan 2015/09/10 22:26:17 This looks redundant; can STE modify the out param
Eugene But (OOO till 7-30) 2015/09/14 23:20:30 Not according to this code: http://opensource.appl
+ }
+
+ dispatch_async(dispatch_get_main_queue(), ^{
+ handlerHolder->call(web::GetSecurityStyleFromTrustResult(trustResult),
+ certVerifierResult.cert_status);
+ });
+ }];
+}
+
- (void)shutDown {
DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::UI);
web::WebThread::PostTask(web::WebThread::IO, FROM_HERE, base::BindBlock(^{

Powered by Google App Engine
This is Rietveld 408576698