 Chromium Code Reviews
 Chromium Code Reviews Issue 416403006:
  Improve the SSL error display when the clock is wrong.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 416403006:
  Improve the SSL error display when the clock is wrong.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_blocking_page.h" | 5 #include "chrome/browser/ssl/ssl_blocking_page.h" | 
| 6 | 6 | 
| 7 #include "base/build_time.h" | 7 #include "base/build_time.h" | 
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" | 
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" | 
| 10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" | 
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 #if !defined(OS_CHROMEOS) | 273 #if !defined(OS_CHROMEOS) | 
| 274 base::LaunchOptions options; | 274 base::LaunchOptions options; | 
| 275 options.wait = false; | 275 options.wait = false; | 
| 276 #if defined(OS_LINUX) | 276 #if defined(OS_LINUX) | 
| 277 options.allow_new_privs = true; | 277 options.allow_new_privs = true; | 
| 278 #endif | 278 #endif | 
| 279 base::LaunchProcess(command, options, NULL); | 279 base::LaunchProcess(command, options, NULL); | 
| 280 #endif | 280 #endif | 
| 281 } | 281 } | 
| 282 | 282 | 
| 283 bool IsErrorDueToBadClock(const base::Time& now, int error) { | |
| 284 if (SSLErrorInfo::NetErrorToErrorType(error) != | |
| 285 SSLErrorInfo::CERT_DATE_INVALID) { | |
| 286 return false; | |
| 287 } | |
| 288 return SSLErrorClassification::IsUserClockInThePast(now) || | |
| 289 SSLErrorClassification::IsUserClockInTheFuture(now); | |
| 290 } | |
| 291 | |
| 283 } // namespace | 292 } // namespace | 
| 284 | 293 | 
| 285 // Note that we always create a navigation entry with SSL errors. | 294 // Note that we always create a navigation entry with SSL errors. | 
| 286 // No error happening loading a sub-resource triggers an interstitial so far. | 295 // No error happening loading a sub-resource triggers an interstitial so far. | 
| 287 SSLBlockingPage::SSLBlockingPage( | 296 SSLBlockingPage::SSLBlockingPage( | 
| 288 content::WebContents* web_contents, | 297 content::WebContents* web_contents, | 
| 289 int cert_error, | 298 int cert_error, | 
| 290 const net::SSLInfo& ssl_info, | 299 const net::SSLInfo& ssl_info, | 
| 291 const GURL& request_url, | 300 const GURL& request_url, | 
| 292 bool overridable, | 301 bool overridable, | 
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 394 base::i18n::WrapStringWithLTRFormatting(&url); | 403 base::i18n::WrapStringWithLTRFormatting(&url); | 
| 395 webui::SetFontAndTextDirection(&load_time_data); | 404 webui::SetFontAndTextDirection(&load_time_data); | 
| 396 | 405 | 
| 397 // Shared values for both the overridable and non-overridable versions. | 406 // Shared values for both the overridable and non-overridable versions. | 
| 398 load_time_data.SetBoolean("ssl", true); | 407 load_time_data.SetBoolean("ssl", true); | 
| 399 load_time_data.SetBoolean("overridable", overridable_); | 408 load_time_data.SetBoolean("overridable", overridable_); | 
| 400 load_time_data.SetString( | 409 load_time_data.SetString( | 
| 401 "tabTitle", l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); | 410 "tabTitle", l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); | 
| 402 load_time_data.SetString( | 411 load_time_data.SetString( | 
| 403 "heading", l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING)); | 412 "heading", l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING)); | 
| 404 if ((SSLErrorClassification::IsUserClockInThePast( | 413 | 
| 405 base::Time::NowFromSystemTime())) | 414 base::Time now = base::Time::NowFromSystemTime(); | 
| 406 && (SSLErrorInfo::NetErrorToErrorType(cert_error_) == | 415 bool bad_clock = IsErrorDueToBadClock(now, cert_error_); | 
| 407 SSLErrorInfo::CERT_DATE_INVALID)) { | 416 if (bad_clock) { | 
| 408 load_time_data.SetString("primaryParagraph", | 417 load_time_data.SetString("primaryParagraph", | 
| 409 l10n_util::GetStringFUTF16( | 418 l10n_util::GetStringFUTF16( | 
| 410 IDS_SSL_CLOCK_ERROR, | 419 IDS_SSL_CLOCK_ERROR, | 
| 411 url, | 420 url, | 
| 412 base::TimeFormatShortDate(base::Time::Now()))); | 421 base::TimeFormatShortDate(now))); | 
| 413 } else { | 422 } else { | 
| 414 load_time_data.SetString( | 423 load_time_data.SetString( | 
| 415 "primaryParagraph", | 424 "primaryParagraph", | 
| 416 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url)); | 425 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url)); | 
| 417 } | 426 } | 
| 427 | |
| 418 load_time_data.SetString( | 428 load_time_data.SetString( | 
| 419 "openDetails", | 429 "openDetails", | 
| 420 l10n_util::GetStringUTF16(IDS_SSL_V2_OPEN_DETAILS_BUTTON)); | 430 l10n_util::GetStringUTF16(IDS_SSL_V2_OPEN_DETAILS_BUTTON)); | 
| 421 load_time_data.SetString( | 431 load_time_data.SetString( | 
| 422 "closeDetails", | 432 "closeDetails", | 
| 423 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOSE_DETAILS_BUTTON)); | 433 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOSE_DETAILS_BUTTON)); | 
| 424 load_time_data.SetString("errorCode", net::ErrorToString(cert_error_)); | 434 load_time_data.SetString("errorCode", net::ErrorToString(cert_error_)); | 
| 425 | 435 | 
| 426 if (overridable_) { // Overridable. | 436 if (overridable_) { | 
| 427 SSLErrorInfo error_info = | 437 SSLErrorInfo error_info = | 
| 428 SSLErrorInfo::CreateError( | 438 SSLErrorInfo::CreateError( | 
| 429 SSLErrorInfo::NetErrorToErrorType(cert_error_), | 439 SSLErrorInfo::NetErrorToErrorType(cert_error_), | 
| 430 ssl_info_.cert.get(), | 440 ssl_info_.cert.get(), | 
| 431 request_url_); | 441 request_url_); | 
| 432 load_time_data.SetString( | 442 if (bad_clock) { | 
| 433 "explanationParagraph", error_info.details()); | 443 load_time_data.SetString("explanationParagraph", | 
| 444 l10n_util::GetStringFUTF16( | |
| 445 IDS_SSL_CLOCK_ERROR_EXPLANATION, url)); | |
| 446 } else { | |
| 447 load_time_data.SetString("explanationParagraph", error_info.details()); | |
| 448 } | |
| 434 load_time_data.SetString( | 449 load_time_data.SetString( | 
| 435 "primaryButtonText", | 450 "primaryButtonText", | 
| 436 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON)); | 451 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON)); | 
| 437 load_time_data.SetString( | 452 if (!bad_clock) { | 
| 
felt
2014/08/12 19:35:08
The "final paragraph" is the sentence with a link
 
palmer
2014/08/12 22:45:33
No, it was an artefact of previous hacking. Fixed
 | |
| 438 "finalParagraph", | 453 load_time_data.SetString( | 
| 439 l10n_util::GetStringFUTF16(IDS_SSL_OVERRIDABLE_PROCEED_PARAGRAPH, url)); | 454 "finalParagraph", | 
| 440 } else { // Non-overridable. | 455 l10n_util::GetStringFUTF16(IDS_SSL_OVERRIDABLE_PROCEED_PARAGRAPH, | 
| 441 load_time_data.SetBoolean("overridable", false); | 456 url)); | 
| 457 } | |
| 458 } else { | |
| 442 SSLErrorInfo::ErrorType type = | 459 SSLErrorInfo::ErrorType type = | 
| 443 SSLErrorInfo::NetErrorToErrorType(cert_error_); | 460 SSLErrorInfo::NetErrorToErrorType(cert_error_); | 
| 444 if (type == SSLErrorInfo::CERT_INVALID && SSLErrorClassification:: | 461 if (type == SSLErrorInfo::CERT_INVALID && SSLErrorClassification:: | 
| 445 IsWindowsVersionSP3OrLower()) { | 462 IsWindowsVersionSP3OrLower()) { | 
| 446 load_time_data.SetString( | 463 load_time_data.SetString( | 
| 447 "explanationParagraph", | 464 "explanationParagraph", | 
| 448 l10n_util::GetStringFUTF16( | 465 l10n_util::GetStringFUTF16( | 
| 449 IDS_SSL_NONOVERRIDABLE_MORE_INVALID_SP3, url)); | 466 IDS_SSL_NONOVERRIDABLE_MORE_INVALID_SP3, url)); | 
| 467 } else if (bad_clock) { | |
| 468 load_time_data.SetString("explanationParagraph", | |
| 469 l10n_util::GetStringFUTF16( | |
| 470 IDS_SSL_CLOCK_ERROR_EXPLANATION, url)); | |
| 450 } else { | 471 } else { | 
| 451 load_time_data.SetString("explanationParagraph", | 472 load_time_data.SetString("explanationParagraph", | 
| 452 l10n_util::GetStringFUTF16( | 473 l10n_util::GetStringFUTF16( | 
| 453 IDS_SSL_NONOVERRIDABLE_MORE, url)); | 474 IDS_SSL_NONOVERRIDABLE_MORE, url)); | 
| 454 } | 475 } | 
| 455 load_time_data.SetString( | 476 load_time_data.SetString( | 
| 456 "primaryButtonText", | 477 "primaryButtonText", | 
| 457 l10n_util::GetStringUTF16(IDS_SSL_NONOVERRIDABLE_RELOAD_BUTTON)); | 478 l10n_util::GetStringUTF16(IDS_SSL_NONOVERRIDABLE_RELOAD_BUTTON)); | 
| 458 // Customize the help link depending on the specific error type. | 479 // Customize the help link depending on the specific error type. | 
| 459 // Only mark as HSTS if none of the more specific error types apply, and use | 480 // Only mark as HSTS if none of the more specific error types apply, and use | 
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 656 // sure we don't clear the captive portal flag, since the interstitial was | 677 // sure we don't clear the captive portal flag, since the interstitial was | 
| 657 // potentially caused by the captive portal. | 678 // potentially caused by the captive portal. | 
| 658 captive_portal_detected_ = captive_portal_detected_ || | 679 captive_portal_detected_ = captive_portal_detected_ || | 
| 659 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); | 680 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); | 
| 660 // Also keep track of non-HTTP portals and error cases. | 681 // Also keep track of non-HTTP portals and error cases. | 
| 661 captive_portal_no_response_ = captive_portal_no_response_ || | 682 captive_portal_no_response_ = captive_portal_no_response_ || | 
| 662 (results->result == captive_portal::RESULT_NO_RESPONSE); | 683 (results->result == captive_portal::RESULT_NO_RESPONSE); | 
| 663 } | 684 } | 
| 664 #endif | 685 #endif | 
| 665 } | 686 } | 
| OLD | NEW |