| 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 <unordered_set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 | 540 |
| 541 void SSLErrorHandler::StartHandlingError() { | 541 void SSLErrorHandler::StartHandlingError() { |
| 542 RecordUMA(HANDLE_ALL); | 542 RecordUMA(HANDLE_ALL); |
| 543 | 543 |
| 544 if (ssl_errors::ErrorInfo::NetErrorToErrorType(cert_error_) == | 544 if (ssl_errors::ErrorInfo::NetErrorToErrorType(cert_error_) == |
| 545 ssl_errors::ErrorInfo::CERT_DATE_INVALID) { | 545 ssl_errors::ErrorInfo::CERT_DATE_INVALID) { |
| 546 HandleCertDateInvalidError(); | 546 HandleCertDateInvalidError(); |
| 547 return; | 547 return; |
| 548 } | 548 } |
| 549 | 549 |
| 550 const net::CertStatus non_name_mismatch_errors = |
| 551 ssl_info_.cert_status ^ net::CERT_STATUS_COMMON_NAME_INVALID; |
| 552 const bool only_error_is_name_mismatch = |
| 553 cert_error_ == net::ERR_CERT_COMMON_NAME_INVALID && |
| 554 (!net::IsCertStatusError(non_name_mismatch_errors) || |
| 555 net::IsCertStatusMinorError(ssl_info_.cert_status)); |
| 556 |
| 550 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) | 557 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 558 // Check known captive portal certificate list if the only error is |
| 559 // name-mismatch. If there are multiple errors, it indicates that the captive |
| 560 // portal landing page itself will have SSL errors, and so it's not a very |
| 561 // helpful place to direct the user to go. |
| 551 if (base::FeatureList::IsEnabled(kCaptivePortalCertificateList) && | 562 if (base::FeatureList::IsEnabled(kCaptivePortalCertificateList) && |
| 552 cert_error_ == net::ERR_CERT_COMMON_NAME_INVALID && | 563 only_error_is_name_mismatch && |
| 553 g_config.Pointer()->IsKnownCaptivePortalCert(ssl_info_)) { | 564 g_config.Pointer()->IsKnownCaptivePortalCert(ssl_info_)) { |
| 554 RecordUMA(CAPTIVE_PORTAL_CERT_FOUND); | 565 RecordUMA(CAPTIVE_PORTAL_CERT_FOUND); |
| 555 ShowCaptivePortalInterstitial( | 566 ShowCaptivePortalInterstitial( |
| 556 GURL(captive_portal::CaptivePortalDetector::kDefaultURL)); | 567 GURL(captive_portal::CaptivePortalDetector::kDefaultURL)); |
| 557 return; | 568 return; |
| 558 } | 569 } |
| 559 #endif | 570 #endif |
| 560 | 571 |
| 561 std::vector<std::string> dns_names; | 572 std::vector<std::string> dns_names; |
| 562 ssl_info_.cert->GetDNSNames(&dns_names); | 573 ssl_info_.cert->GetDNSNames(&dns_names); |
| 563 DCHECK(!dns_names.empty()); | 574 DCHECK(!dns_names.empty()); |
| 564 GURL suggested_url; | 575 GURL suggested_url; |
| 565 if (IsSSLCommonNameMismatchHandlingEnabled() && | 576 if (IsSSLCommonNameMismatchHandlingEnabled() && |
| 566 cert_error_ == net::ERR_CERT_COMMON_NAME_INVALID && | 577 cert_error_ == net::ERR_CERT_COMMON_NAME_INVALID && |
| 567 delegate_->IsErrorOverridable() && | 578 delegate_->IsErrorOverridable() && |
| 568 delegate_->GetSuggestedUrl(dns_names, &suggested_url)) { | 579 delegate_->GetSuggestedUrl(dns_names, &suggested_url)) { |
| 569 RecordUMA(WWW_MISMATCH_FOUND); | 580 RecordUMA(WWW_MISMATCH_FOUND); |
| 570 net::CertStatus extra_cert_errors = | |
| 571 ssl_info_.cert_status ^ net::CERT_STATUS_COMMON_NAME_INVALID; | |
| 572 | 581 |
| 573 // Show the SSL intersitial if |CERT_STATUS_COMMON_NAME_INVALID| is not | 582 // Show the SSL interstitial if |CERT_STATUS_COMMON_NAME_INVALID| is not |
| 574 // the only error. Need not check for captive portal in this case. | 583 // the only error. Need not check for captive portal in this case. |
| 575 // (See the comment below). | 584 // (See the comment below). |
| 576 if (net::IsCertStatusError(extra_cert_errors) && | 585 if (!only_error_is_name_mismatch) { |
| 577 !net::IsCertStatusMinorError(ssl_info_.cert_status)) { | |
| 578 ShowSSLInterstitial(); | 586 ShowSSLInterstitial(); |
| 579 return; | 587 return; |
| 580 } | 588 } |
| 581 delegate_->CheckSuggestedUrl( | 589 delegate_->CheckSuggestedUrl( |
| 582 suggested_url, | 590 suggested_url, |
| 583 base::Bind(&SSLErrorHandler::CommonNameMismatchHandlerCallback, | 591 base::Bind(&SSLErrorHandler::CommonNameMismatchHandlerCallback, |
| 584 weak_ptr_factory_.GetWeakPtr())); | 592 weak_ptr_factory_.GetWeakPtr())); |
| 585 timer_.Start(FROM_HERE, g_config.Pointer()->interstitial_delay(), this, | 593 timer_.Start(FROM_HERE, g_config.Pointer()->interstitial_delay(), this, |
| 586 &SSLErrorHandler::ShowSSLInterstitial); | 594 &SSLErrorHandler::ShowSSLInterstitial); |
| 587 | 595 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 network_time::NetworkTimeTracker* tracker = | 768 network_time::NetworkTimeTracker* tracker = |
| 761 g_config.Pointer()->network_time_tracker(); | 769 g_config.Pointer()->network_time_tracker(); |
| 762 ssl_errors::ClockState clock_state = ssl_errors::GetClockState(now, tracker); | 770 ssl_errors::ClockState clock_state = ssl_errors::GetClockState(now, tracker); |
| 763 if (clock_state == ssl_errors::CLOCK_STATE_FUTURE || | 771 if (clock_state == ssl_errors::CLOCK_STATE_FUTURE || |
| 764 clock_state == ssl_errors::CLOCK_STATE_PAST) { | 772 clock_state == ssl_errors::CLOCK_STATE_PAST) { |
| 765 ShowBadClockInterstitial(now, clock_state); | 773 ShowBadClockInterstitial(now, clock_state); |
| 766 return; // |this| is deleted after showing the interstitial. | 774 return; // |this| is deleted after showing the interstitial. |
| 767 } | 775 } |
| 768 ShowSSLInterstitial(); | 776 ShowSSLInterstitial(); |
| 769 } | 777 } |
| OLD | NEW |