Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/ssl/ssl_error_handler.h" | 5 #include "chrome/browser/ssl/ssl_error_handler.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <unordered_set> | |
| 8 #include <utility> | 9 #include <utility> |
| 9 | 10 |
| 10 #include "base/callback_helpers.h" | 11 #include "base/callback_helpers.h" |
| 11 #include "base/feature_list.h" | 12 #include "base/feature_list.h" |
| 13 #include "base/files/file_util.h" | |
| 12 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
| 13 #include "base/macros.h" | 15 #include "base/macros.h" |
| 14 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
| 15 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 16 #include "base/threading/non_thread_safe.h" | 18 #include "base/threading/non_thread_safe.h" |
| 17 #include "base/time/clock.h" | 19 #include "base/time/clock.h" |
| 18 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 19 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/ssl/bad_clock_blocking_page.h" | 23 #include "chrome/browser/ssl/bad_clock_blocking_page.h" |
| 22 #include "chrome/browser/ssl/ssl_blocking_page.h" | 24 #include "chrome/browser/ssl/ssl_blocking_page.h" |
| 23 #include "chrome/browser/ssl/ssl_cert_reporter.h" | 25 #include "chrome/browser/ssl/ssl_cert_reporter.h" |
| 26 #include "chrome/browser/ssl/ssl_error_assistant.pb.h" | |
| 24 #include "chrome/common/features.h" | 27 #include "chrome/common/features.h" |
| 28 #include "chrome/grit/browser_resources.h" | |
| 25 #include "components/network_time/network_time_tracker.h" | 29 #include "components/network_time/network_time_tracker.h" |
| 26 #include "components/ssl_errors/error_classification.h" | 30 #include "components/ssl_errors/error_classification.h" |
| 27 #include "components/ssl_errors/error_info.h" | 31 #include "components/ssl_errors/error_info.h" |
| 32 #include "content/public/browser/browser_thread.h" | |
| 28 #include "content/public/browser/navigation_handle.h" | 33 #include "content/public/browser/navigation_handle.h" |
| 29 #include "content/public/browser/notification_service.h" | 34 #include "content/public/browser/notification_service.h" |
| 30 #include "content/public/browser/notification_source.h" | 35 #include "content/public/browser/notification_source.h" |
| 31 #include "content/public/browser/render_frame_host.h" | 36 #include "content/public/browser/render_frame_host.h" |
| 32 #include "content/public/browser/web_contents.h" | 37 #include "content/public/browser/web_contents.h" |
| 33 #include "net/base/net_errors.h" | 38 #include "net/base/net_errors.h" |
| 39 #include "ui/base/resource/resource_bundle.h" | |
| 34 | 40 |
| 35 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) | 41 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 36 #include "chrome/browser/captive_portal/captive_portal_service.h" | 42 #include "chrome/browser/captive_portal/captive_portal_service.h" |
| 37 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" | 43 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" |
| 38 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" | 44 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" |
| 39 #include "chrome/browser/ssl/captive_portal_blocking_page.h" | 45 #include "chrome/browser/ssl/captive_portal_blocking_page.h" |
| 40 #endif | 46 #endif |
| 41 | 47 |
| 42 namespace { | 48 namespace { |
| 43 | 49 |
| 44 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) | 50 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 45 const base::Feature kCaptivePortalInterstitial{ | 51 const base::Feature kCaptivePortalInterstitial{ |
| 46 "CaptivePortalInterstitial", base::FEATURE_ENABLED_BY_DEFAULT}; | 52 "CaptivePortalInterstitial", base::FEATURE_ENABLED_BY_DEFAULT}; |
| 53 | |
| 54 const base::Feature kCaptivePortalCertificateList{ | |
| 55 "CaptivePortalCertificateList", base::FEATURE_DISABLED_BY_DEFAULT}; | |
| 47 #endif | 56 #endif |
| 48 | 57 |
| 49 const base::Feature kSSLCommonNameMismatchHandling{ | 58 const base::Feature kSSLCommonNameMismatchHandling{ |
| 50 "SSLCommonNameMismatchHandling", base::FEATURE_ENABLED_BY_DEFAULT}; | 59 "SSLCommonNameMismatchHandling", base::FEATURE_ENABLED_BY_DEFAULT}; |
| 51 | 60 |
| 52 const char kHistogram[] = "interstitial.ssl_error_handler"; | |
| 53 | |
| 54 // Default delay in milliseconds before displaying the SSL interstitial. | 61 // Default delay in milliseconds before displaying the SSL interstitial. |
| 55 // This can be changed in tests. | 62 // This can be changed in tests. |
| 56 // - If there is a name mismatch and a suggested URL available result arrives | 63 // - If there is a name mismatch and a suggested URL available result arrives |
| 57 // during this time, the user is redirected to the suggester URL. | 64 // during this time, the user is redirected to the suggester URL. |
| 58 // - If a "captive portal detected" result arrives during this time, | 65 // - If a "captive portal detected" result arrives during this time, |
| 59 // a captive portal interstitial is displayed. | 66 // a captive portal interstitial is displayed. |
| 60 // - Otherwise, an SSL interstitial is displayed. | 67 // - Otherwise, an SSL interstitial is displayed. |
| 61 const int64_t kInterstitialDelayInMilliseconds = 3000; | 68 const int64_t kInterstitialDelayInMilliseconds = 3000; |
| 62 | 69 |
| 70 const char kHistogram[] = "interstitial.ssl_error_handler"; | |
| 71 | |
| 63 // Adds a message to console after navigation commits and then, deletes itself. | 72 // Adds a message to console after navigation commits and then, deletes itself. |
| 64 // Also deletes itself if the navigation is stopped. | 73 // Also deletes itself if the navigation is stopped. |
| 65 class CommonNameMismatchRedirectObserver | 74 class CommonNameMismatchRedirectObserver |
| 66 : public content::WebContentsObserver, | 75 : public content::WebContentsObserver, |
| 67 public content::WebContentsUserData<CommonNameMismatchRedirectObserver> { | 76 public content::WebContentsUserData<CommonNameMismatchRedirectObserver> { |
| 68 public: | 77 public: |
| 69 static void AddToConsoleAfterNavigation( | 78 static void AddToConsoleAfterNavigation( |
| 70 content::WebContents* web_contents, | 79 content::WebContents* web_contents, |
| 71 const std::string& request_url_hostname, | 80 const std::string& request_url_hostname, |
| 72 const std::string& suggested_url_hostname) { | 81 const std::string& suggested_url_hostname) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 | 128 |
| 120 void RecordUMA(SSLErrorHandler::UMAEvent event) { | 129 void RecordUMA(SSLErrorHandler::UMAEvent event) { |
| 121 UMA_HISTOGRAM_ENUMERATION(kHistogram, event, | 130 UMA_HISTOGRAM_ENUMERATION(kHistogram, event, |
| 122 SSLErrorHandler::SSL_ERROR_HANDLER_EVENT_COUNT); | 131 SSLErrorHandler::SSL_ERROR_HANDLER_EVENT_COUNT); |
| 123 } | 132 } |
| 124 | 133 |
| 125 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) | 134 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 126 bool IsCaptivePortalInterstitialEnabled() { | 135 bool IsCaptivePortalInterstitialEnabled() { |
| 127 return base::FeatureList::IsEnabled(kCaptivePortalInterstitial); | 136 return base::FeatureList::IsEnabled(kCaptivePortalInterstitial); |
| 128 } | 137 } |
| 138 | |
| 139 // Reads the SSL error assistant configuration from the resource bundle. | |
| 140 void ReadErrorAssistantProtoFromResourceBundle(std::string* binary_pb) { | |
| 141 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 142 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | |
| 143 bundle.GetRawDataResource(IDR_SSL_ERROR_ASSISTANT_PB).CopyToString(binary_pb); | |
| 144 } | |
| 145 | |
| 146 std::unique_ptr<std::unordered_set<std::string>> LoadCaptivePortalCertHashes( | |
| 147 const chrome_browser_ssl::SSLErrorAssistantConfig& proto) { | |
| 148 std::unique_ptr<std::unordered_set<std::string>> hashes( | |
| 149 new std::unordered_set<std::string>()); | |
| 150 for (const chrome_browser_ssl::CaptivePortalCert& cert : | |
| 151 proto.captive_portal_cert()) { | |
| 152 hashes.get()->insert(cert.sha256_hash()); | |
| 153 } | |
| 154 return hashes; | |
| 155 } | |
| 129 #endif | 156 #endif |
| 130 | 157 |
| 131 bool IsSSLCommonNameMismatchHandlingEnabled() { | 158 bool IsSSLCommonNameMismatchHandlingEnabled() { |
| 132 return base::FeatureList::IsEnabled(kSSLCommonNameMismatchHandling); | 159 return base::FeatureList::IsEnabled(kSSLCommonNameMismatchHandling); |
| 133 } | 160 } |
| 134 | 161 |
| 135 // Configuration for SSLErrorHandler. | 162 // Configuration for SSLErrorHandler. |
| 136 class ConfigSingleton : public base::NonThreadSafe { | 163 class ConfigSingleton : public base::NonThreadSafe { |
| 137 public: | 164 public: |
| 138 ConfigSingleton(); | 165 ConfigSingleton(); |
| 139 | 166 |
| 140 base::TimeDelta interstitial_delay() const; | 167 base::TimeDelta interstitial_delay() const; |
| 141 SSLErrorHandler::TimerStartedCallback* timer_started_callback() const; | 168 SSLErrorHandler::TimerStartedCallback* timer_started_callback() const; |
| 142 base::Clock* clock() const; | 169 base::Clock* clock() const; |
| 143 network_time::NetworkTimeTracker* network_time_tracker() const; | 170 network_time::NetworkTimeTracker* network_time_tracker() const; |
| 144 | 171 |
| 172 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) | |
| 173 // Returns true if any of the SHA256 hashes in |ssl_info| is of a captive | |
| 174 // portal certificate. The set of captive portal hashes is loaded on first | |
| 175 // use. | |
| 176 bool IsKnownCaptivePortalCert(const net::SSLInfo& ssl_info); | |
| 177 #endif | |
| 178 | |
| 179 // Testing methods: | |
| 180 void ResetForTesting(); | |
| 145 void SetInterstitialDelayForTesting(const base::TimeDelta& delay); | 181 void SetInterstitialDelayForTesting(const base::TimeDelta& delay); |
| 146 void SetTimerStartedCallbackForTesting( | 182 void SetTimerStartedCallbackForTesting( |
| 147 SSLErrorHandler::TimerStartedCallback* callback); | 183 SSLErrorHandler::TimerStartedCallback* callback); |
| 148 void SetClockForTesting(base::Clock* clock); | 184 void SetClockForTesting(base::Clock* clock); |
| 149 void SetNetworkTimeTrackerForTesting( | 185 void SetNetworkTimeTrackerForTesting( |
| 150 network_time::NetworkTimeTracker* tracker); | 186 network_time::NetworkTimeTracker* tracker); |
| 151 | 187 |
| 188 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) | |
| 189 void SetErrorAssistantProtoForTesting( | |
| 190 const chrome_browser_ssl::SSLErrorAssistantConfig& error_assistant_proto); | |
| 191 #endif | |
| 192 | |
| 152 private: | 193 private: |
| 153 base::TimeDelta interstitial_delay_; | 194 base::TimeDelta interstitial_delay_; |
| 154 | 195 |
| 155 // Callback to call when the interstitial timer is started. Used for | 196 // Callback to call when the interstitial timer is started. Used for |
| 156 // testing. | 197 // testing. |
| 157 SSLErrorHandler::TimerStartedCallback* timer_started_callback_ = nullptr; | 198 SSLErrorHandler::TimerStartedCallback* timer_started_callback_ = nullptr; |
| 158 | 199 |
| 159 // The clock to use when deciding which error type to display. Used for | 200 // The clock to use when deciding which error type to display. Used for |
| 160 // testing. | 201 // testing. |
| 161 base::Clock* testing_clock_ = nullptr; | 202 base::Clock* testing_clock_ = nullptr; |
| 162 | 203 |
| 163 network_time::NetworkTimeTracker* network_time_tracker_ = nullptr; | 204 network_time::NetworkTimeTracker* network_time_tracker_ = nullptr; |
| 205 | |
| 206 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) | |
| 207 // SPKI hashes belonging to certs treated as captive portals. Null until the | |
| 208 // first time IsKnownCaptivePortalCert() or SetErrorAssistantProtoForTesting() | |
| 209 // is called. | |
| 210 std::unique_ptr<std::unordered_set<std::string>> captive_portal_spki_hashes_; | |
| 211 #endif | |
| 164 }; | 212 }; |
| 165 | 213 |
| 166 ConfigSingleton::ConfigSingleton() | 214 ConfigSingleton::ConfigSingleton() |
| 167 : interstitial_delay_( | 215 : interstitial_delay_( |
| 168 base::TimeDelta::FromMilliseconds(kInterstitialDelayInMilliseconds)) { | 216 base::TimeDelta::FromMilliseconds(kInterstitialDelayInMilliseconds)) { |
| 169 } | 217 } |
| 170 | 218 |
| 171 base::TimeDelta ConfigSingleton::interstitial_delay() const { | 219 base::TimeDelta ConfigSingleton::interstitial_delay() const { |
| 172 return interstitial_delay_; | 220 return interstitial_delay_; |
| 173 } | 221 } |
| 174 | 222 |
| 175 SSLErrorHandler::TimerStartedCallback* ConfigSingleton::timer_started_callback() | 223 SSLErrorHandler::TimerStartedCallback* ConfigSingleton::timer_started_callback() |
| 176 const { | 224 const { |
| 177 return timer_started_callback_; | 225 return timer_started_callback_; |
| 178 } | 226 } |
| 179 | 227 |
| 180 network_time::NetworkTimeTracker* ConfigSingleton::network_time_tracker() | 228 network_time::NetworkTimeTracker* ConfigSingleton::network_time_tracker() |
| 181 const { | 229 const { |
| 182 return network_time_tracker_ ? network_time_tracker_ | 230 return network_time_tracker_ ? network_time_tracker_ |
| 183 : g_browser_process->network_time_tracker(); | 231 : g_browser_process->network_time_tracker(); |
| 184 } | 232 } |
| 185 | 233 |
| 186 base::Clock* ConfigSingleton::clock() const { | 234 base::Clock* ConfigSingleton::clock() const { |
| 187 return testing_clock_; | 235 return testing_clock_; |
| 188 } | 236 } |
| 189 | 237 |
| 238 void ConfigSingleton::ResetForTesting() { | |
| 239 interstitial_delay_ = | |
| 240 base::TimeDelta::FromMilliseconds(kInterstitialDelayInMilliseconds); | |
| 241 timer_started_callback_ = nullptr; | |
| 242 network_time_tracker_ = nullptr; | |
| 243 testing_clock_ = nullptr; | |
| 244 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) | |
| 245 captive_portal_spki_hashes_.reset(); | |
| 246 #endif | |
| 247 } | |
| 248 | |
| 190 void ConfigSingleton::SetInterstitialDelayForTesting( | 249 void ConfigSingleton::SetInterstitialDelayForTesting( |
| 191 const base::TimeDelta& delay) { | 250 const base::TimeDelta& delay) { |
| 192 interstitial_delay_ = delay; | 251 interstitial_delay_ = delay; |
| 193 } | 252 } |
| 194 | 253 |
| 195 void ConfigSingleton::SetTimerStartedCallbackForTesting( | 254 void ConfigSingleton::SetTimerStartedCallbackForTesting( |
| 196 SSLErrorHandler::TimerStartedCallback* callback) { | 255 SSLErrorHandler::TimerStartedCallback* callback) { |
| 197 DCHECK(!callback || !callback->is_null()); | 256 DCHECK(!callback || !callback->is_null()); |
| 198 timer_started_callback_ = callback; | 257 timer_started_callback_ = callback; |
| 199 } | 258 } |
| 200 | 259 |
| 201 void ConfigSingleton::SetClockForTesting(base::Clock* clock) { | 260 void ConfigSingleton::SetClockForTesting(base::Clock* clock) { |
| 202 testing_clock_ = clock; | 261 testing_clock_ = clock; |
| 203 } | 262 } |
| 204 | 263 |
| 205 void ConfigSingleton::SetNetworkTimeTrackerForTesting( | 264 void ConfigSingleton::SetNetworkTimeTrackerForTesting( |
| 206 network_time::NetworkTimeTracker* tracker) { | 265 network_time::NetworkTimeTracker* tracker) { |
| 207 network_time_tracker_ = tracker; | 266 network_time_tracker_ = tracker; |
| 208 } | 267 } |
| 209 | 268 |
| 269 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) | |
| 270 void ConfigSingleton::SetErrorAssistantProtoForTesting( | |
| 271 const chrome_browser_ssl::SSLErrorAssistantConfig& error_assistant_proto) { | |
| 272 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 273 DCHECK(!captive_portal_spki_hashes_); | |
| 274 captive_portal_spki_hashes_ = | |
| 275 LoadCaptivePortalCertHashes(error_assistant_proto); | |
| 276 } | |
| 277 | |
| 278 bool ConfigSingleton::IsKnownCaptivePortalCert(const net::SSLInfo& ssl_info) { | |
| 279 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 280 if (!captive_portal_spki_hashes_) { | |
| 281 std::string binary_proto; | |
| 282 ReadErrorAssistantProtoFromResourceBundle(&binary_proto); | |
| 283 chrome_browser_ssl::SSLErrorAssistantConfig proto; | |
| 284 proto.ParseFromString(binary_proto); | |
| 285 captive_portal_spki_hashes_ = LoadCaptivePortalCertHashes(proto); | |
|
Ryan Sleevi
2017/02/02 02:24:37
The zero-copy solution I was suggesting previously
meacer
2017/02/06 23:39:17
Done, thanks for pointing to this.
| |
| 286 } | |
| 287 | |
| 288 for (const net::HashValue& hash_value : ssl_info.public_key_hashes) { | |
| 289 if (hash_value.tag != net::HASH_VALUE_SHA256) { | |
| 290 continue; | |
| 291 } | |
| 292 if (captive_portal_spki_hashes_->find(hash_value.ToString()) != | |
|
Ryan Sleevi
2017/02/02 02:24:36
If you wanted to avoid forcing every hash to be st
meacer
2017/02/06 23:39:17
I looked into providing a hash function, but was a
| |
| 293 captive_portal_spki_hashes_->end()) { | |
| 294 return true; | |
| 295 } | |
| 296 } | |
| 297 return false; | |
| 298 } | |
| 299 #endif | |
| 300 | |
| 210 class SSLErrorHandlerDelegateImpl : public SSLErrorHandler::Delegate { | 301 class SSLErrorHandlerDelegateImpl : public SSLErrorHandler::Delegate { |
| 211 public: | 302 public: |
| 212 SSLErrorHandlerDelegateImpl( | 303 SSLErrorHandlerDelegateImpl( |
| 213 content::WebContents* web_contents, | 304 content::WebContents* web_contents, |
| 214 const net::SSLInfo& ssl_info, | 305 const net::SSLInfo& ssl_info, |
| 215 Profile* const profile, | 306 Profile* const profile, |
| 216 int cert_error, | 307 int cert_error, |
| 217 int options_mask, | 308 int options_mask, |
| 218 const GURL& request_url, | 309 const GURL& request_url, |
| 219 std::unique_ptr<SSLCertReporter> ssl_cert_reporter, | 310 std::unique_ptr<SSLCertReporter> ssl_cert_reporter, |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 358 std::unique_ptr<SSLErrorHandler::Delegate>( | 449 std::unique_ptr<SSLErrorHandler::Delegate>( |
| 359 new SSLErrorHandlerDelegateImpl( | 450 new SSLErrorHandlerDelegateImpl( |
| 360 web_contents, ssl_info, profile, cert_error, options_mask, | 451 web_contents, ssl_info, profile, cert_error, options_mask, |
| 361 request_url, std::move(ssl_cert_reporter), callback)), | 452 request_url, std::move(ssl_cert_reporter), callback)), |
| 362 web_contents, profile, cert_error, ssl_info, request_url, callback); | 453 web_contents, profile, cert_error, ssl_info, request_url, callback); |
| 363 web_contents->SetUserData(UserDataKey(), error_handler); | 454 web_contents->SetUserData(UserDataKey(), error_handler); |
| 364 error_handler->StartHandlingError(); | 455 error_handler->StartHandlingError(); |
| 365 } | 456 } |
| 366 | 457 |
| 367 // static | 458 // static |
| 459 void SSLErrorHandler::ResetConfigForTesting() { | |
| 460 g_config.Pointer()->ResetForTesting(); | |
| 461 } | |
| 462 | |
| 463 // static | |
| 368 void SSLErrorHandler::SetInterstitialDelayForTesting( | 464 void SSLErrorHandler::SetInterstitialDelayForTesting( |
| 369 const base::TimeDelta& delay) { | 465 const base::TimeDelta& delay) { |
| 370 g_config.Pointer()->SetInterstitialDelayForTesting(delay); | 466 g_config.Pointer()->SetInterstitialDelayForTesting(delay); |
| 371 } | 467 } |
| 372 | 468 |
| 373 // static | 469 // static |
| 374 void SSLErrorHandler::SetInterstitialTimerStartedCallbackForTesting( | 470 void SSLErrorHandler::SetInterstitialTimerStartedCallbackForTesting( |
| 375 TimerStartedCallback* callback) { | 471 TimerStartedCallback* callback) { |
| 376 g_config.Pointer()->SetTimerStartedCallbackForTesting(callback); | 472 g_config.Pointer()->SetTimerStartedCallbackForTesting(callback); |
| 377 } | 473 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 389 | 485 |
| 390 // static | 486 // static |
| 391 std::string SSLErrorHandler::GetHistogramNameForTesting() { | 487 std::string SSLErrorHandler::GetHistogramNameForTesting() { |
| 392 return kHistogram; | 488 return kHistogram; |
| 393 } | 489 } |
| 394 | 490 |
| 395 bool SSLErrorHandler::IsTimerRunningForTesting() const { | 491 bool SSLErrorHandler::IsTimerRunningForTesting() const { |
| 396 return timer_.IsRunning(); | 492 return timer_.IsRunning(); |
| 397 } | 493 } |
| 398 | 494 |
| 495 void SSLErrorHandler::SetErrorAssistantProtoForTesting( | |
| 496 const chrome_browser_ssl::SSLErrorAssistantConfig& config_proto) { | |
| 497 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) | |
| 498 g_config.Pointer()->SetErrorAssistantProtoForTesting(config_proto); | |
| 499 #endif | |
| 500 } | |
| 501 | |
| 399 SSLErrorHandler::SSLErrorHandler( | 502 SSLErrorHandler::SSLErrorHandler( |
| 400 std::unique_ptr<Delegate> delegate, | 503 std::unique_ptr<Delegate> delegate, |
| 401 content::WebContents* web_contents, | 504 content::WebContents* web_contents, |
| 402 Profile* profile, | 505 Profile* profile, |
| 403 int cert_error, | 506 int cert_error, |
| 404 const net::SSLInfo& ssl_info, | 507 const net::SSLInfo& ssl_info, |
| 405 const GURL& request_url, | 508 const GURL& request_url, |
| 406 const base::Callback<void(content::CertificateRequestResultType)>& callback) | 509 const base::Callback<void(content::CertificateRequestResultType)>& callback) |
| 407 : content::WebContentsObserver(web_contents), | 510 : content::WebContentsObserver(web_contents), |
| 408 delegate_(std::move(delegate)), | 511 delegate_(std::move(delegate)), |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 419 | 522 |
| 420 void SSLErrorHandler::StartHandlingError() { | 523 void SSLErrorHandler::StartHandlingError() { |
| 421 RecordUMA(HANDLE_ALL); | 524 RecordUMA(HANDLE_ALL); |
| 422 | 525 |
| 423 if (ssl_errors::ErrorInfo::NetErrorToErrorType(cert_error_) == | 526 if (ssl_errors::ErrorInfo::NetErrorToErrorType(cert_error_) == |
| 424 ssl_errors::ErrorInfo::CERT_DATE_INVALID) { | 527 ssl_errors::ErrorInfo::CERT_DATE_INVALID) { |
| 425 HandleCertDateInvalidError(); | 528 HandleCertDateInvalidError(); |
| 426 return; | 529 return; |
| 427 } | 530 } |
| 428 | 531 |
| 532 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) | |
| 533 if (base::FeatureList::IsEnabled(kCaptivePortalCertificateList) && | |
| 534 cert_error_ == net::ERR_CERT_COMMON_NAME_INVALID && | |
| 535 g_config.Pointer()->IsKnownCaptivePortalCert(ssl_info_)) { | |
| 536 RecordUMA(CAPTIVE_PORTAL_CERT_FOUND); | |
| 537 ShowCaptivePortalInterstitial( | |
| 538 GURL(captive_portal::CaptivePortalDetector::kDefaultURL)); | |
| 539 return; | |
| 540 } | |
| 541 #endif | |
| 542 | |
| 429 std::vector<std::string> dns_names; | 543 std::vector<std::string> dns_names; |
| 430 ssl_info_.cert->GetDNSNames(&dns_names); | 544 ssl_info_.cert->GetDNSNames(&dns_names); |
| 431 DCHECK(!dns_names.empty()); | 545 DCHECK(!dns_names.empty()); |
| 432 GURL suggested_url; | 546 GURL suggested_url; |
| 433 if (IsSSLCommonNameMismatchHandlingEnabled() && | 547 if (IsSSLCommonNameMismatchHandlingEnabled() && |
| 434 cert_error_ == net::ERR_CERT_COMMON_NAME_INVALID && | 548 cert_error_ == net::ERR_CERT_COMMON_NAME_INVALID && |
| 435 delegate_->IsErrorOverridable() && | 549 delegate_->IsErrorOverridable() && |
| 436 delegate_->GetSuggestedUrl(dns_names, &suggested_url)) { | 550 delegate_->GetSuggestedUrl(dns_names, &suggested_url)) { |
| 437 RecordUMA(WWW_MISMATCH_FOUND); | 551 RecordUMA(WWW_MISMATCH_FOUND); |
| 438 net::CertStatus extra_cert_errors = | 552 net::CertStatus extra_cert_errors = |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 628 network_time::NetworkTimeTracker* tracker = | 742 network_time::NetworkTimeTracker* tracker = |
| 629 g_config.Pointer()->network_time_tracker(); | 743 g_config.Pointer()->network_time_tracker(); |
| 630 ssl_errors::ClockState clock_state = ssl_errors::GetClockState(now, tracker); | 744 ssl_errors::ClockState clock_state = ssl_errors::GetClockState(now, tracker); |
| 631 if (clock_state == ssl_errors::CLOCK_STATE_FUTURE || | 745 if (clock_state == ssl_errors::CLOCK_STATE_FUTURE || |
| 632 clock_state == ssl_errors::CLOCK_STATE_PAST) { | 746 clock_state == ssl_errors::CLOCK_STATE_PAST) { |
| 633 ShowBadClockInterstitial(now, clock_state); | 747 ShowBadClockInterstitial(now, clock_state); |
| 634 return; // |this| is deleted after showing the interstitial. | 748 return; // |this| is deleted after showing the interstitial. |
| 635 } | 749 } |
| 636 ShowSSLInterstitial(); | 750 ShowSSLInterstitial(); |
| 637 } | 751 } |
| OLD | NEW |