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

Side by Side Diff: chrome/browser/ssl/ssl_error_handler.cc

Issue 2690333006: Captive portal certificate list should be checked when name mismatch is the only error (Closed)
Patch Set: estark comments Created 3 years, 10 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 unified diff | Download patch
OLDNEW
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
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.
estark 2017/02/25 01:33:18 nit: since we keep forgetting, it would probably b
meacer 2017/02/27 23:50:58 I think that's right, because I can't find any oth
551 if (base::FeatureList::IsEnabled(kCaptivePortalCertificateList) && 560 if (base::FeatureList::IsEnabled(kCaptivePortalCertificateList) &&
552 cert_error_ == net::ERR_CERT_COMMON_NAME_INVALID && 561 only_error_is_name_mismatch &&
553 g_config.Pointer()->IsKnownCaptivePortalCert(ssl_info_)) { 562 g_config.Pointer()->IsKnownCaptivePortalCert(ssl_info_)) {
554 RecordUMA(CAPTIVE_PORTAL_CERT_FOUND); 563 RecordUMA(CAPTIVE_PORTAL_CERT_FOUND);
555 ShowCaptivePortalInterstitial( 564 ShowCaptivePortalInterstitial(
556 GURL(captive_portal::CaptivePortalDetector::kDefaultURL)); 565 GURL(captive_portal::CaptivePortalDetector::kDefaultURL));
557 return; 566 return;
558 } 567 }
559 #endif 568 #endif
560 569
561 std::vector<std::string> dns_names; 570 std::vector<std::string> dns_names;
562 ssl_info_.cert->GetDNSNames(&dns_names); 571 ssl_info_.cert->GetDNSNames(&dns_names);
563 DCHECK(!dns_names.empty()); 572 DCHECK(!dns_names.empty());
564 GURL suggested_url; 573 GURL suggested_url;
565 if (IsSSLCommonNameMismatchHandlingEnabled() && 574 if (IsSSLCommonNameMismatchHandlingEnabled() &&
566 cert_error_ == net::ERR_CERT_COMMON_NAME_INVALID && 575 cert_error_ == net::ERR_CERT_COMMON_NAME_INVALID &&
567 delegate_->IsErrorOverridable() && 576 delegate_->IsErrorOverridable() &&
568 delegate_->GetSuggestedUrl(dns_names, &suggested_url)) { 577 delegate_->GetSuggestedUrl(dns_names, &suggested_url)) {
569 RecordUMA(WWW_MISMATCH_FOUND); 578 RecordUMA(WWW_MISMATCH_FOUND);
570 net::CertStatus extra_cert_errors =
571 ssl_info_.cert_status ^ net::CERT_STATUS_COMMON_NAME_INVALID;
572 579
573 // Show the SSL intersitial if |CERT_STATUS_COMMON_NAME_INVALID| is not 580 // Show the SSL intersitial if |CERT_STATUS_COMMON_NAME_INVALID| is not
574 // the only error. Need not check for captive portal in this case. 581 // the only error. Need not check for captive portal in this case.
575 // (See the comment below). 582 // (See the comment below).
576 if (net::IsCertStatusError(extra_cert_errors) && 583 if (!only_error_is_name_mismatch) {
577 !net::IsCertStatusMinorError(ssl_info_.cert_status)) {
578 ShowSSLInterstitial(); 584 ShowSSLInterstitial();
579 return; 585 return;
580 } 586 }
581 delegate_->CheckSuggestedUrl( 587 delegate_->CheckSuggestedUrl(
582 suggested_url, 588 suggested_url,
583 base::Bind(&SSLErrorHandler::CommonNameMismatchHandlerCallback, 589 base::Bind(&SSLErrorHandler::CommonNameMismatchHandlerCallback,
584 weak_ptr_factory_.GetWeakPtr())); 590 weak_ptr_factory_.GetWeakPtr()));
585 timer_.Start(FROM_HERE, g_config.Pointer()->interstitial_delay(), this, 591 timer_.Start(FROM_HERE, g_config.Pointer()->interstitial_delay(), this,
586 &SSLErrorHandler::ShowSSLInterstitial); 592 &SSLErrorHandler::ShowSSLInterstitial);
587 593
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 network_time::NetworkTimeTracker* tracker = 766 network_time::NetworkTimeTracker* tracker =
761 g_config.Pointer()->network_time_tracker(); 767 g_config.Pointer()->network_time_tracker();
762 ssl_errors::ClockState clock_state = ssl_errors::GetClockState(now, tracker); 768 ssl_errors::ClockState clock_state = ssl_errors::GetClockState(now, tracker);
763 if (clock_state == ssl_errors::CLOCK_STATE_FUTURE || 769 if (clock_state == ssl_errors::CLOCK_STATE_FUTURE ||
764 clock_state == ssl_errors::CLOCK_STATE_PAST) { 770 clock_state == ssl_errors::CLOCK_STATE_PAST) {
765 ShowBadClockInterstitial(now, clock_state); 771 ShowBadClockInterstitial(now, clock_state);
766 return; // |this| is deleted after showing the interstitial. 772 return; // |this| is deleted after showing the interstitial.
767 } 773 }
768 ShowSSLInterstitial(); 774 ShowSSLInterstitial();
769 } 775 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698