Commit 97f6153d authored by Yi Su's avatar Yi Su Committed by Commit Bot

Move certificate files into //ios/web/security.

This CL moves all certificate related files from //ios/web/net into
//ios/web/security. This is a prerequisite work for navigation refactor.

Bug: 956511,942244
Change-Id: Iddf802f75b8ca7038e00a062fcb26773d7948a2f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1624572Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Yi Su <mrsuyi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#662542}
parent e102db8b
...@@ -336,13 +336,9 @@ source_set("ios_web_net_unittests") { ...@@ -336,13 +336,9 @@ source_set("ios_web_net_unittests") {
] ]
sources = [ sources = [
"net/cert_host_pair_unittest.cc",
"net/cert_policy_unittest.cc",
"net/cookies/crw_wk_http_cookie_store_unittest.mm", "net/cookies/crw_wk_http_cookie_store_unittest.mm",
"net/cookies/wk_cookie_util_unittest.mm", "net/cookies/wk_cookie_util_unittest.mm",
"net/cookies/wk_http_system_cookie_store_unittest.mm", "net/cookies/wk_http_system_cookie_store_unittest.mm",
"net/crw_cert_verification_controller_unittest.mm",
"net/crw_ssl_status_updater_unittest.mm",
] ]
} }
......
...@@ -9,26 +9,12 @@ source_set("net") { ...@@ -9,26 +9,12 @@ source_set("net") {
"//base", "//base",
"//ios/net", "//ios/net",
"//ios/web:core", "//ios/web:core",
"//ios/web/common",
"//ios/web/navigation:core",
"//ios/web/navigation:navigation_manager_util",
"//ios/web/navigation:wk_navigation_util",
"//ios/web/public", "//ios/web/public",
"//ios/web/security",
"//net",
] ]
sources = [ sources = [
"cert_host_pair.cc",
"cert_host_pair.h",
"cert_policy.cc",
"certificate_policy_cache.cc",
"cookie_notification_bridge.h", "cookie_notification_bridge.h",
"cookie_notification_bridge.mm", "cookie_notification_bridge.mm",
"crw_cert_verification_controller.h",
"crw_cert_verification_controller.mm",
"crw_ssl_status_updater.h",
"crw_ssl_status_updater.mm",
] ]
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
......
...@@ -10,6 +10,7 @@ source_set("security") { ...@@ -10,6 +10,7 @@ source_set("security") {
"//base", "//base",
"//ios/web/common", "//ios/web/common",
"//ios/web/navigation:core", "//ios/web/navigation:core",
"//ios/web/navigation:navigation_manager_util",
"//ios/web/public", "//ios/web/public",
"//ios/web/web_state:web_state_impl_header", "//ios/web/web_state:web_state_impl_header",
"//ios/web/web_state/ui:web_view_js_utils", "//ios/web/web_state/ui:web_view_js_utils",
...@@ -18,6 +19,14 @@ source_set("security") { ...@@ -18,6 +19,14 @@ source_set("security") {
] ]
sources = [ sources = [
"cert_host_pair.cc",
"cert_host_pair.h",
"cert_policy.cc",
"certificate_policy_cache.cc",
"crw_cert_verification_controller.h",
"crw_cert_verification_controller.mm",
"crw_ssl_status_updater.h",
"crw_ssl_status_updater.mm",
"ssl_status.cc", "ssl_status.cc",
"web_interstitial_impl.h", "web_interstitial_impl.h",
"web_interstitial_impl.mm", "web_interstitial_impl.mm",
...@@ -36,18 +45,23 @@ source_set("unittests") { ...@@ -36,18 +45,23 @@ source_set("unittests") {
"//crypto", "//crypto",
"//ios/testing:ocmock_support", "//ios/testing:ocmock_support",
"//ios/web", "//ios/web",
"//ios/web/navigation:core", "//ios/web/navigation",
"//ios/web/public", "//ios/web/public",
"//ios/web/public/test", "//ios/web/public/test",
"//ios/web/public/test/fakes", "//ios/web/public/test/fakes",
"//ios/web/test/fakes", "//ios/web/test/fakes",
"//ios/web/web_state:web_state_impl_header", "//ios/web/web_state:web_state_impl_header",
"//net", "//net",
"//net:test_support",
"//testing/gmock", "//testing/gmock",
"//testing/gtest", "//testing/gtest",
] ]
sources = [ sources = [
"cert_host_pair_unittest.cc",
"cert_policy_unittest.cc",
"crw_cert_verification_controller_unittest.mm",
"crw_ssl_status_updater_unittest.mm",
"ssl_status_unittest.cc", "ssl_status_unittest.cc",
"web_interstitial_unittest.mm", "web_interstitial_unittest.mm",
"wk_web_view_security_util_unittest.mm", "wk_web_view_security_util_unittest.mm",
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ios/web/net/cert_host_pair.h" #include "ios/web/security/cert_host_pair.h"
#include <utility> #include <utility>
...@@ -24,4 +24,4 @@ bool CertHostPair::operator<(const CertHostPair& other) const { ...@@ -24,4 +24,4 @@ bool CertHostPair::operator<(const CertHostPair& other) const {
return std::tie(host_, cert_hash_) < std::tie(other.host_, other.cert_hash_); return std::tie(host_, cert_hash_) < std::tie(other.host_, other.cert_hash_);
} }
} // web } // namespace web
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef IOS_WEB_NET_CERT_HOST_PAIR_H_ #ifndef IOS_WEB_SECURITY_CERT_HOST_PAIR_H_
#define IOS_WEB_NET_CERT_HOST_PAIR_H_ #define IOS_WEB_SECURITY_CERT_HOST_PAIR_H_
#include <string> #include <string>
...@@ -37,4 +37,4 @@ class CertHostPair { ...@@ -37,4 +37,4 @@ class CertHostPair {
} // namespace web } // namespace web
#endif // IOS_WEB_NET_CERT_HOST_PAIR_H_ #endif // IOS_WEB_SECURITY_CERT_HOST_PAIR_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ios/web/net/cert_host_pair.h" #include "ios/web/security/cert_host_pair.h"
#include "net/test/cert_test_util.h" #include "net/test/cert_test_util.h"
#include "net/test/test_data_directory.h" #include "net/test/test_data_directory.h"
......
...@@ -9,11 +9,9 @@ ...@@ -9,11 +9,9 @@
namespace web { namespace web {
CertPolicy::CertPolicy() { CertPolicy::CertPolicy() {}
}
CertPolicy::~CertPolicy() { CertPolicy::~CertPolicy() {}
}
// We consider a given |cert| to be a match to a saved allowed cert if the // We consider a given |cert| to be a match to a saved allowed cert if the
// |error| is an exact match to or subset of the errors in the saved CertStatus. // |error| is an exact match to or subset of the errors in the saved CertStatus.
......
...@@ -61,9 +61,8 @@ TEST_F(CertPolicyTest, Policy) { ...@@ -61,9 +61,8 @@ TEST_F(CertPolicyTest, Policy) {
policy.Check(webkit_cert.get(), net::CERT_STATUS_COMMON_NAME_INVALID)); policy.Check(webkit_cert.get(), net::CERT_STATUS_COMMON_NAME_INVALID));
// Test adding one certificate with two errors. // Test adding one certificate with two errors.
policy.Allow( policy.Allow(google_cert.get(), net::CERT_STATUS_DATE_INVALID |
google_cert.get(), net::CERT_STATUS_AUTHORITY_INVALID);
net::CERT_STATUS_DATE_INVALID | net::CERT_STATUS_AUTHORITY_INVALID);
EXPECT_EQ(CertPolicy::ALLOWED, EXPECT_EQ(CertPolicy::ALLOWED,
policy.Check(google_cert.get(), net::CERT_STATUS_DATE_INVALID)); policy.Check(google_cert.get(), net::CERT_STATUS_DATE_INVALID));
EXPECT_EQ( EXPECT_EQ(
......
...@@ -9,11 +9,9 @@ ...@@ -9,11 +9,9 @@
namespace web { namespace web {
CertificatePolicyCache::CertificatePolicyCache() { CertificatePolicyCache::CertificatePolicyCache() {}
}
CertificatePolicyCache::~CertificatePolicyCache() { CertificatePolicyCache::~CertificatePolicyCache() {}
}
void CertificatePolicyCache::AllowCertForHost(net::X509Certificate* cert, void CertificatePolicyCache::AllowCertForHost(net::X509Certificate* cert,
const std::string& host, const std::string& host,
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef IOS_WEB_NET_CRW_CERT_VERIFICATION_CONTROLLER_H_ #ifndef IOS_WEB_SECURITY_CRW_CERT_VERIFICATION_CONTROLLER_H_
#define IOS_WEB_NET_CRW_CERT_VERIFICATION_CONTROLLER_H_ #define IOS_WEB_SECURITY_CRW_CERT_VERIFICATION_CONTROLLER_H_
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
...@@ -91,4 +91,4 @@ typedef void (^StatusQueryHandler)(web::SecurityStyle, net::CertStatus); ...@@ -91,4 +91,4 @@ typedef void (^StatusQueryHandler)(web::SecurityStyle, net::CertStatus);
@end @end
#endif // IOS_WEB_NET_CRW_CERT_VERIFICATION_CONTROLLER_H_ #endif // IOS_WEB_SECURITY_CRW_CERT_VERIFICATION_CONTROLLER_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#import "ios/web/net/crw_cert_verification_controller.h" #import "ios/web/security/crw_cert_verification_controller.h"
#include <memory> #include <memory>
...@@ -42,11 +42,12 @@ using web::WebThread; ...@@ -42,11 +42,12 @@ using web::WebThread;
// Decides the policy for the given |trust| which was rejected by iOS and the // Decides the policy for the given |trust| which was rejected by iOS and the
// given |host| and calls |handler| on completion. Must be called on UI thread. // given |host| and calls |handler| on completion. Must be called on UI thread.
// |handler| can not be null and will be called on UI thread. // |handler| can not be null and will be called on UI thread.
- (void) - (void)decideLoadPolicyForRejectedTrustResult:(SecTrustResultType)trustResult
decideLoadPolicyForRejectedTrustResult:(SecTrustResultType)trustResult serverTrust:
serverTrust:(base::ScopedCFTypeRef<SecTrustRef>)trust (base::ScopedCFTypeRef<SecTrustRef>)trust
host:(NSString*)host host:(NSString*)host
completionHandler:(web::PolicyDecisionHandler)handler; completionHandler:
(web::PolicyDecisionHandler)handler;
// Verifies the given |trust| using SecTrustRef API. |completionHandler| cannot // Verifies the given |trust| using SecTrustRef API. |completionHandler| cannot
// be null and will be called on UI thread or never be called if the worker task // be null and will be called on UI thread or never be called if the worker task
...@@ -57,10 +58,10 @@ decideLoadPolicyForRejectedTrustResult:(SecTrustResultType)trustResult ...@@ -57,10 +58,10 @@ decideLoadPolicyForRejectedTrustResult:(SecTrustResultType)trustResult
// Returns cert accept policy for the given SecTrust result. |trustResult| must // Returns cert accept policy for the given SecTrust result. |trustResult| must
// not be for a valid cert. Must be called on IO thread. // not be for a valid cert. Must be called on IO thread.
- (web::CertAcceptPolicy) - (web::CertAcceptPolicy)
loadPolicyForRejectedTrustResult:(SecTrustResultType)trustResult loadPolicyForRejectedTrustResult:(SecTrustResultType)trustResult
certStatus:(net::CertStatus)certStatus certStatus:(net::CertStatus)certStatus
serverTrust:(SecTrustRef)trust serverTrust:(SecTrustRef)trust
host:(NSString*)host; host:(NSString*)host;
@end @end
...@@ -111,8 +112,8 @@ loadPolicyForRejectedTrustResult:(SecTrustResultType)trustResult ...@@ -111,8 +112,8 @@ loadPolicyForRejectedTrustResult:(SecTrustResultType)trustResult
web::SecurityStyle securityStyle = web::SecurityStyle securityStyle =
web::GetSecurityStyleFromTrustResult(trustResult); web::GetSecurityStyleFromTrustResult(trustResult);
net::CertStatus certStatus = net::CertStatus certStatus = [self certStatusFromTrustResult:trustResult
[self certStatusFromTrustResult:trustResult serverTrust:trust]; serverTrust:trust];
completionHandler(securityStyle, certStatus); completionHandler(securityStyle, certStatus);
}]; }];
} }
...@@ -162,35 +163,38 @@ loadPolicyForRejectedTrustResult:(SecTrustResultType)trustResult ...@@ -162,35 +163,38 @@ loadPolicyForRejectedTrustResult:(SecTrustResultType)trustResult
return certStatus; return certStatus;
} }
- (void) - (void)decideLoadPolicyForRejectedTrustResult:(SecTrustResultType)trustResult
decideLoadPolicyForRejectedTrustResult:(SecTrustResultType)trustResult serverTrust:
serverTrust:(base::ScopedCFTypeRef<SecTrustRef>)trust (base::ScopedCFTypeRef<SecTrustRef>)trust
host:(NSString*)host host:(NSString*)host
completionHandler:(web::PolicyDecisionHandler)handler { completionHandler:
(web::PolicyDecisionHandler)handler {
DCHECK_CURRENTLY_ON(WebThread::UI); DCHECK_CURRENTLY_ON(WebThread::UI);
DCHECK(handler); DCHECK(handler);
TaskTraits traits{WebThread::IO, TaskShutdownBehavior::BLOCK_SHUTDOWN}; TaskTraits traits{WebThread::IO, TaskShutdownBehavior::BLOCK_SHUTDOWN};
base::PostTaskWithTraits( base::PostTaskWithTraits(FROM_HERE, traits, base::BindOnce(^{
FROM_HERE, traits, base::BindOnce(^{ // |loadPolicyForRejectedTrustResult:certStatus:serverTrust:host:|
// |loadPolicyForRejectedTrustResult:certStatus:serverTrust:host:| can // can only be called on IO thread.
// only be called on IO thread. net::CertStatus certStatus =
net::CertStatus certStatus = [self certStatusFromTrustResult:trustResult
[self certStatusFromTrustResult:trustResult serverTrust:trust]; serverTrust:trust];
web::CertAcceptPolicy policy = web::CertAcceptPolicy policy = [self
[self loadPolicyForRejectedTrustResult:trustResult loadPolicyForRejectedTrustResult:trustResult
certStatus:certStatus certStatus:certStatus
serverTrust:trust.get() serverTrust:trust.get()
host:host]; host:host];
// TODO(crbug.com/872372): This should use PostTaskWithTraits to post to // TODO(crbug.com/872372): This should use
// WebThread::UI with BLOCK_SHUTDOWN once shutdown behaviors are // PostTaskWithTraits to post to WebThread::UI with
// supported on the UI thread. BLOCK_SHUTDOWN is necessary because // BLOCK_SHUTDOWN once shutdown behaviors are
// WKWebView throws an exception if the completion handler doesn't run. // supported on the UI thread. BLOCK_SHUTDOWN is
dispatch_async(dispatch_get_main_queue(), ^{ // necessary because WKWebView throws an exception
handler(policy, certStatus); // if the completion handler doesn't run.
}); dispatch_async(dispatch_get_main_queue(), ^{
})); handler(policy, certStatus);
});
}));
} }
- (void)verifyTrust:(base::ScopedCFTypeRef<SecTrustRef>)trust - (void)verifyTrust:(base::ScopedCFTypeRef<SecTrustRef>)trust
...@@ -216,10 +220,10 @@ decideLoadPolicyForRejectedTrustResult:(SecTrustResultType)trustResult ...@@ -216,10 +220,10 @@ decideLoadPolicyForRejectedTrustResult:(SecTrustResultType)trustResult
} }
- (web::CertAcceptPolicy) - (web::CertAcceptPolicy)
loadPolicyForRejectedTrustResult:(SecTrustResultType)trustResult loadPolicyForRejectedTrustResult:(SecTrustResultType)trustResult
certStatus:(net::CertStatus)certStatus certStatus:(net::CertStatus)certStatus
serverTrust:(SecTrustRef)trust serverTrust:(SecTrustRef)trust
host:(NSString*)host { host:(NSString*)host {
DCHECK_CURRENTLY_ON(WebThread::IO); DCHECK_CURRENTLY_ON(WebThread::IO);
DCHECK_NE(web::SECURITY_STYLE_AUTHENTICATED, DCHECK_NE(web::SECURITY_STYLE_AUTHENTICATED,
web::GetSecurityStyleFromTrustResult(trustResult)); web::GetSecurityStyleFromTrustResult(trustResult));
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#import "ios/web/net/crw_cert_verification_controller.h" #import "ios/web/security/crw_cert_verification_controller.h"
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#import "base/test/ios/wait_util.h" #import "base/test/ios/wait_util.h"
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef IOS_WEB_NET_CRW_SSL_STATUS_UPDATER_H_ #ifndef IOS_WEB_SECURITY_CRW_SSL_STATUS_UPDATER_H_
#define IOS_WEB_NET_CRW_SSL_STATUS_UPDATER_H_ #define IOS_WEB_SECURITY_CRW_SSL_STATUS_UPDATER_H_
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <Security/Security.h> #import <Security/Security.h>
...@@ -66,7 +66,7 @@ typedef void (^StatusQueryHandler)(web::SecurityStyle, net::CertStatus); ...@@ -66,7 +66,7 @@ typedef void (^StatusQueryHandler)(web::SecurityStyle, net::CertStatus);
@end @end
// Delegate for CRWSSLStatusUpdater. // Delegate for CRWSSLStatusUpdater.
@protocol CRWSSLStatusUpdaterDelegate<NSObject> @protocol CRWSSLStatusUpdaterDelegate <NSObject>
@optional @optional
...@@ -78,4 +78,4 @@ typedef void (^StatusQueryHandler)(web::SecurityStyle, net::CertStatus); ...@@ -78,4 +78,4 @@ typedef void (^StatusQueryHandler)(web::SecurityStyle, net::CertStatus);
@end @end
#endif // IOS_WEB_NET_CRW_SSL_STATUS_UPDATER_H_ #endif // IOS_WEB_SECURITY_CRW_SSL_STATUS_UPDATER_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#import "ios/web/net/crw_ssl_status_updater.h" #import "ios/web/security/crw_ssl_status_updater.h"
#import "base/strings/sys_string_conversions.h" #import "base/strings/sys_string_conversions.h"
#import "ios/web/navigation/navigation_item_impl.h" #import "ios/web/navigation/navigation_item_impl.h"
...@@ -170,8 +170,8 @@ using web::SecurityStyle; ...@@ -170,8 +170,8 @@ using web::SecurityStyle;
} }
- (void)didChangeSSLStatusForNavigationItem:(web::NavigationItem*)navItem { - (void)didChangeSSLStatusForNavigationItem:(web::NavigationItem*)navItem {
if ([_delegate respondsToSelector: if ([_delegate respondsToSelector:@selector
@selector(SSLStatusUpdater:didChangeSSLStatusForNavigationItem:)]) { (SSLStatusUpdater:didChangeSSLStatusForNavigationItem:)]) {
[_delegate SSLStatusUpdater:self [_delegate SSLStatusUpdater:self
didChangeSSLStatusForNavigationItem:navItem]; didChangeSSLStatusForNavigationItem:navItem];
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#import "ios/web/net/crw_ssl_status_updater.h" #import "ios/web/security/crw_ssl_status_updater.h"
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#include "base/mac/scoped_block.h" #include "base/mac/scoped_block.h"
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
// Mocks CRWSSLStatusUpdaterTestDataSource. // Mocks CRWSSLStatusUpdaterTestDataSource.
@interface CRWSSLStatusUpdaterTestDataSource @interface CRWSSLStatusUpdaterTestDataSource
: NSObject<CRWSSLStatusUpdaterDataSource> { : NSObject <CRWSSLStatusUpdaterDataSource> {
StatusQueryHandler _verificationCompletionHandler; StatusQueryHandler _verificationCompletionHandler;
} }
......
...@@ -63,9 +63,6 @@ ...@@ -63,9 +63,6 @@
#import "ios/web/navigation/wk_navigation_action_policy_util.h" #import "ios/web/navigation/wk_navigation_action_policy_util.h"
#import "ios/web/navigation/wk_navigation_action_util.h" #import "ios/web/navigation/wk_navigation_action_util.h"
#import "ios/web/navigation/wk_navigation_util.h" #import "ios/web/navigation/wk_navigation_util.h"
#include "ios/web/net/cert_host_pair.h"
#import "ios/web/net/crw_cert_verification_controller.h"
#import "ios/web/net/crw_ssl_status_updater.h"
#include "ios/web/public/browser_state.h" #include "ios/web/public/browser_state.h"
#import "ios/web/public/download/download_controller.h" #import "ios/web/public/download/download_controller.h"
#include "ios/web/public/favicon_url.h" #include "ios/web/public/favicon_url.h"
...@@ -88,6 +85,9 @@ ...@@ -88,6 +85,9 @@
#import "ios/web/public/web_state/web_state.h" #import "ios/web/public/web_state/web_state.h"
#import "ios/web/public/web_state/web_state_policy_decider.h" #import "ios/web/public/web_state/web_state_policy_decider.h"
#include "ios/web/public/webui/web_ui_ios.h" #include "ios/web/public/webui/web_ui_ios.h"
#include "ios/web/security/cert_host_pair.h"
#import "ios/web/security/crw_cert_verification_controller.h"
#import "ios/web/security/crw_ssl_status_updater.h"
#import "ios/web/security/web_interstitial_impl.h" #import "ios/web/security/web_interstitial_impl.h"
#import "ios/web/security/wk_web_view_security_util.h" #import "ios/web/security/wk_web_view_security_util.h"
#import "ios/web/web_state/error_translation_util.h" #import "ios/web/web_state/error_translation_util.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment