Chromium Code Reviews| 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/ui/website_settings/website_settings.h" | 5 #include "chrome/browser/ui/website_settings/website_settings.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 break; | 186 break; |
| 187 case security_state::SecurityStateModel:: | 187 case security_state::SecurityStateModel:: |
| 188 MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE: | 188 MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE: |
| 189 *status = WebsiteSettings::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE; | 189 *status = WebsiteSettings::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE; |
| 190 *details = l10n_util::GetStringUTF16( | 190 *details = l10n_util::GetStringUTF16( |
| 191 IDS_WEBSITE_SETTINGS_UNWANTED_SOFTWARE_DETAILS); | 191 IDS_WEBSITE_SETTINGS_UNWANTED_SOFTWARE_DETAILS); |
| 192 break; | 192 break; |
| 193 } | 193 } |
| 194 } | 194 } |
| 195 | 195 |
| 196 // Returns true if any of the given statuses match |status|. | |
| 197 bool CertificateTransparencyStatusMatchAny( | |
| 198 const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses, | |
| 199 net::ct::SCTVerifyStatus status) { | |
| 200 for (const auto& verify_status : sct_verify_statuses) { | |
| 201 if (verify_status == status) | |
| 202 return true; | |
| 203 } | |
| 204 return false; | |
| 205 } | |
| 206 | |
| 207 int GetSiteIdentityDetailsMessageByCTInfo( | |
| 208 const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses, | |
| 209 bool is_ev) { | |
| 210 // No SCTs - no CT information. | |
| 211 if (sct_verify_statuses.empty()) | |
| 212 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_NO_CT | |
| 213 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_NO_CT); | |
| 214 | |
| 215 // Any valid SCT. | |
| 216 if (CertificateTransparencyStatusMatchAny(sct_verify_statuses, | |
| 217 net::ct::SCT_STATUS_OK)) | |
| 218 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_VERIFIED | |
| 219 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_VERIFIED); | |
| 220 | |
| 221 // Any invalid SCT. | |
| 222 if (CertificateTransparencyStatusMatchAny( | |
| 223 sct_verify_statuses, net::ct::SCT_STATUS_INVALID_TIMESTAMP) || | |
| 224 CertificateTransparencyStatusMatchAny( | |
| 225 sct_verify_statuses, net::ct::SCT_STATUS_INVALID_SIGNATURE)) | |
| 226 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_INVALID | |
| 227 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_INVALID); | |
| 228 | |
| 229 // All SCTs are from unknown logs. | |
| 230 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_UNVERIFIED | |
| 231 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_UNVERIFIED); | |
| 232 } | |
| 233 | |
| 234 // This function will return SITE_IDENTITY_STATUS_CERT or | |
| 235 // SITE_IDENTITY_STATUS_EV_CERT depending on |is_ev| unless all SCTs | |
| 236 // failed verification, in which case it will return | |
| 237 // SITE_IDENTITY_STATUS_ERROR. | |
| 238 WebsiteSettings::SiteIdentityStatus GetSiteIdentityStatusByCTInfo( | |
| 239 const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses, | |
| 240 bool is_ev) { | |
| 241 if (sct_verify_statuses.empty() || | |
| 242 CertificateTransparencyStatusMatchAny(sct_verify_statuses, | |
| 243 net::ct::SCT_STATUS_OK)) | |
| 244 return is_ev ? WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT | |
| 245 : WebsiteSettings::SITE_IDENTITY_STATUS_CERT; | |
| 246 | |
| 247 return WebsiteSettings::SITE_IDENTITY_STATUS_CT_ERROR; | |
| 248 } | |
| 249 | |
| 250 base::string16 GetSimpleSiteName(const GURL& url) { | 196 base::string16 GetSimpleSiteName(const GURL& url) { |
| 251 return url_formatter::FormatUrlForSecurityDisplay( | 197 return url_formatter::FormatUrlForSecurityDisplay( |
| 252 url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS); | 198 url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS); |
| 253 } | 199 } |
| 254 | 200 |
| 255 ChooserContextBase* GetUsbChooserContext(Profile* profile) { | 201 ChooserContextBase* GetUsbChooserContext(Profile* profile) { |
| 256 return UsbChooserContextFactory::GetForProfile(profile); | 202 return UsbChooserContextFactory::GetForProfile(profile); |
| 257 } | 203 } |
| 258 | 204 |
| 259 // The list of chooser types that need to display entries in the Website | 205 // The list of chooser types that need to display entries in the Website |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 465 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE; | 411 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE; |
| 466 site_identity_details_ = | 412 site_identity_details_ = |
| 467 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE); | 413 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE); |
| 468 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE; | 414 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE; |
| 469 return; | 415 return; |
| 470 } | 416 } |
| 471 | 417 |
| 472 // Identity section. | 418 // Identity section. |
| 473 certificate_ = security_info.certificate; | 419 certificate_ = security_info.certificate; |
| 474 | 420 |
| 421 bool is_ev = !!(security_info.cert_status & net::CERT_STATUS_IS_EV); | |
|
lgarron
2016/11/14 23:30:57
Nit: Keep this inside the `else`, since it's only
estark
2016/11/15 00:56:24
Done.
| |
| 475 if (security_info.malicious_content_status != | 422 if (security_info.malicious_content_status != |
| 476 security_state::SecurityStateModel::MALICIOUS_CONTENT_STATUS_NONE) { | 423 security_state::SecurityStateModel::MALICIOUS_CONTENT_STATUS_NONE) { |
| 477 // The site has been flagged by Safe Browsing as dangerous. | 424 // The site has been flagged by Safe Browsing as dangerous. |
| 478 GetSiteIdentityByMaliciousContentStatus( | 425 GetSiteIdentityByMaliciousContentStatus( |
| 479 security_info.malicious_content_status, &site_identity_status_, | 426 security_info.malicious_content_status, &site_identity_status_, |
| 480 &site_identity_details_); | 427 &site_identity_details_); |
| 481 } else if (certificate_ && | 428 } else if (certificate_ && |
| 482 (!net::IsCertStatusError(security_info.cert_status) || | 429 (!net::IsCertStatusError(security_info.cert_status) || |
| 483 net::IsCertStatusMinorError(security_info.cert_status))) { | 430 net::IsCertStatusMinorError(security_info.cert_status))) { |
| 484 // HTTPS with no or minor errors. | 431 // HTTPS with no or minor errors. |
| 485 if (security_info.security_level == | 432 if (security_info.security_level == |
| 486 SecurityStateModel::SECURE_WITH_POLICY_INSTALLED_CERT) { | 433 SecurityStateModel::SECURE_WITH_POLICY_INSTALLED_CERT) { |
| 487 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT; | 434 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT; |
| 488 site_identity_details_ = l10n_util::GetStringFUTF16( | 435 site_identity_details_ = l10n_util::GetStringFUTF16( |
| 489 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host())); | 436 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host())); |
| 490 } else if (net::IsCertStatusMinorError(security_info.cert_status)) { | 437 } else if (net::IsCertStatusMinorError(security_info.cert_status)) { |
| 491 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN; | 438 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN; |
| 492 base::string16 issuer_name( | 439 base::string16 issuer_name( |
| 493 UTF8ToUTF16(certificate_->issuer().GetDisplayName())); | 440 UTF8ToUTF16(certificate_->issuer().GetDisplayName())); |
| 494 if (issuer_name.empty()) { | 441 if (issuer_name.empty()) { |
| 495 issuer_name.assign(l10n_util::GetStringUTF16( | 442 issuer_name.assign(l10n_util::GetStringUTF16( |
| 496 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); | 443 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); |
| 497 } | 444 } |
| 498 | 445 |
| 499 site_identity_details_.assign(l10n_util::GetStringFUTF16( | 446 site_identity_details_.assign(l10n_util::GetStringFUTF16( |
| 500 GetSiteIdentityDetailsMessageByCTInfo( | 447 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name)); |
| 501 security_info.sct_verify_statuses, false /* not EV */), | |
| 502 issuer_name)); | |
| 503 | 448 |
| 504 site_identity_details_ += ASCIIToUTF16("\n\n"); | 449 site_identity_details_ += ASCIIToUTF16("\n\n"); |
| 505 if (security_info.cert_status & | 450 if (security_info.cert_status & |
| 506 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) { | 451 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) { |
| 507 site_identity_details_ += l10n_util::GetStringUTF16( | 452 site_identity_details_ += l10n_util::GetStringUTF16( |
| 508 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION); | 453 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION); |
| 509 } else if (security_info.cert_status & | 454 } else if (security_info.cert_status & |
| 510 net::CERT_STATUS_NO_REVOCATION_MECHANISM) { | 455 net::CERT_STATUS_NO_REVOCATION_MECHANISM) { |
| 511 site_identity_details_ += l10n_util::GetStringUTF16( | 456 site_identity_details_ += l10n_util::GetStringUTF16( |
| 512 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM); | 457 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM); |
| 513 } else { | 458 } else { |
| 514 NOTREACHED() << "Need to specify string for this warning"; | 459 NOTREACHED() << "Need to specify string for this warning"; |
| 515 } | 460 } |
| 516 } else { | 461 } else { |
| 517 if (security_info.cert_status & net::CERT_STATUS_IS_EV) { | 462 // No major or minor errors. |
| 463 if (is_ev) { | |
| 518 // EV HTTPS page. | 464 // EV HTTPS page. |
| 519 site_identity_status_ = GetSiteIdentityStatusByCTInfo( | 465 site_identity_status_ = SITE_IDENTITY_STATUS_EV_CERT; |
| 520 security_info.sct_verify_statuses, true); | |
| 521 DCHECK(!certificate_->subject().organization_names.empty()); | 466 DCHECK(!certificate_->subject().organization_names.empty()); |
| 522 organization_name_ = | 467 organization_name_ = |
| 523 UTF8ToUTF16(certificate_->subject().organization_names[0]); | 468 UTF8ToUTF16(certificate_->subject().organization_names[0]); |
| 524 // An EV Cert is required to have a city (localityName) and country but | 469 // An EV Cert is required to have a city (localityName) and country but |
| 525 // state is "if any". | 470 // state is "if any". |
| 526 DCHECK(!certificate_->subject().locality_name.empty()); | 471 DCHECK(!certificate_->subject().locality_name.empty()); |
| 527 DCHECK(!certificate_->subject().country_name.empty()); | 472 DCHECK(!certificate_->subject().country_name.empty()); |
| 528 base::string16 locality; | 473 base::string16 locality; |
| 529 if (!certificate_->subject().state_or_province_name.empty()) { | 474 if (!certificate_->subject().state_or_province_name.empty()) { |
| 530 locality = l10n_util::GetStringFUTF16( | 475 locality = l10n_util::GetStringFUTF16( |
| 531 IDS_PAGEINFO_ADDRESS, | 476 IDS_PAGEINFO_ADDRESS, |
| 532 UTF8ToUTF16(certificate_->subject().locality_name), | 477 UTF8ToUTF16(certificate_->subject().locality_name), |
| 533 UTF8ToUTF16(certificate_->subject().state_or_province_name), | 478 UTF8ToUTF16(certificate_->subject().state_or_province_name), |
| 534 UTF8ToUTF16(certificate_->subject().country_name)); | 479 UTF8ToUTF16(certificate_->subject().country_name)); |
| 535 } else { | 480 } else { |
| 536 locality = l10n_util::GetStringFUTF16( | 481 locality = l10n_util::GetStringFUTF16( |
| 537 IDS_PAGEINFO_PARTIAL_ADDRESS, | 482 IDS_PAGEINFO_PARTIAL_ADDRESS, |
| 538 UTF8ToUTF16(certificate_->subject().locality_name), | 483 UTF8ToUTF16(certificate_->subject().locality_name), |
| 539 UTF8ToUTF16(certificate_->subject().country_name)); | 484 UTF8ToUTF16(certificate_->subject().country_name)); |
| 540 } | 485 } |
| 541 DCHECK(!certificate_->subject().organization_names.empty()); | 486 DCHECK(!certificate_->subject().organization_names.empty()); |
| 542 site_identity_details_.assign(l10n_util::GetStringFUTF16( | 487 site_identity_details_.assign(l10n_util::GetStringFUTF16( |
| 543 GetSiteIdentityDetailsMessageByCTInfo( | 488 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_VERIFIED, |
| 544 security_info.sct_verify_statuses, true /* is EV */), | |
| 545 UTF8ToUTF16(certificate_->subject().organization_names[0]), | 489 UTF8ToUTF16(certificate_->subject().organization_names[0]), |
| 546 locality, | 490 locality, UTF8ToUTF16(certificate_->issuer().GetDisplayName()))); |
| 547 UTF8ToUTF16(certificate_->issuer().GetDisplayName()))); | |
| 548 } else { | 491 } else { |
| 549 // Non-EV OK HTTPS page. | 492 // Non-EV OK HTTPS page. |
| 550 site_identity_status_ = GetSiteIdentityStatusByCTInfo( | 493 site_identity_status_ = SITE_IDENTITY_STATUS_CERT; |
| 551 security_info.sct_verify_statuses, false); | |
| 552 base::string16 issuer_name( | 494 base::string16 issuer_name( |
| 553 UTF8ToUTF16(certificate_->issuer().GetDisplayName())); | 495 UTF8ToUTF16(certificate_->issuer().GetDisplayName())); |
| 554 if (issuer_name.empty()) { | 496 if (issuer_name.empty()) { |
| 555 issuer_name.assign(l10n_util::GetStringUTF16( | 497 issuer_name.assign(l10n_util::GetStringUTF16( |
| 556 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); | 498 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); |
| 557 } | 499 } |
| 558 | 500 |
| 559 site_identity_details_.assign(l10n_util::GetStringFUTF16( | 501 site_identity_details_.assign(l10n_util::GetStringFUTF16( |
| 560 GetSiteIdentityDetailsMessageByCTInfo( | 502 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name)); |
| 561 security_info.sct_verify_statuses, false /* not EV */), | |
| 562 issuer_name)); | |
| 563 } | 503 } |
| 564 switch (security_info.sha1_deprecation_status) { | 504 switch (security_info.sha1_deprecation_status) { |
| 565 case SecurityStateModel::DEPRECATED_SHA1_MINOR: | 505 case SecurityStateModel::DEPRECATED_SHA1_MINOR: |
| 566 site_identity_status_ = | 506 site_identity_status_ = |
| 567 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR; | 507 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR; |
| 568 site_identity_details_ += | 508 site_identity_details_ += |
| 569 UTF8ToUTF16("\n\n") + | 509 UTF8ToUTF16("\n\n") + |
| 570 l10n_util::GetStringUTF16( | 510 l10n_util::GetStringUTF16( |
| 571 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM_MINO R); | 511 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM_MINO R); |
| 572 break; | 512 break; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 742 // attention to the issue. If the site does not provide a certificate because | 682 // attention to the issue. If the site does not provide a certificate because |
| 743 // it was loaded over an unencrypted connection, don't select the Connection | 683 // it was loaded over an unencrypted connection, don't select the Connection |
| 744 // Tab. | 684 // Tab. |
| 745 WebsiteSettingsUI::TabId tab_id = WebsiteSettingsUI::TAB_ID_PERMISSIONS; | 685 WebsiteSettingsUI::TabId tab_id = WebsiteSettingsUI::TAB_ID_PERMISSIONS; |
| 746 if (site_connection_status_ == SITE_CONNECTION_STATUS_ENCRYPTED_ERROR || | 686 if (site_connection_status_ == SITE_CONNECTION_STATUS_ENCRYPTED_ERROR || |
| 747 site_connection_status_ == | 687 site_connection_status_ == |
| 748 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE || | 688 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE || |
| 749 site_connection_status_ == | 689 site_connection_status_ == |
| 750 SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE || | 690 SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE || |
| 751 site_identity_status_ == SITE_IDENTITY_STATUS_ERROR || | 691 site_identity_status_ == SITE_IDENTITY_STATUS_ERROR || |
| 752 site_identity_status_ == SITE_IDENTITY_STATUS_CT_ERROR || | |
| 753 site_identity_status_ == SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN || | 692 site_identity_status_ == SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN || |
| 754 site_identity_status_ == SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT || | 693 site_identity_status_ == SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT || |
| 755 site_identity_status_ == | 694 site_identity_status_ == |
| 756 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR || | 695 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR || |
| 757 site_identity_status_ == | 696 site_identity_status_ == |
| 758 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR) { | 697 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR) { |
| 759 tab_id = WebsiteSettingsUI::TAB_ID_CONNECTION; | 698 tab_id = WebsiteSettingsUI::TAB_ID_CONNECTION; |
| 760 RecordWebsiteSettingsAction( | 699 RecordWebsiteSettingsAction( |
| 761 WEBSITE_SETTINGS_CONNECTION_TAB_SHOWN_IMMEDIATELY); | 700 WEBSITE_SETTINGS_CONNECTION_TAB_SHOWN_IMMEDIATELY); |
| 762 } | 701 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 861 info.connection_status = site_connection_status_; | 800 info.connection_status = site_connection_status_; |
| 862 info.connection_status_description = | 801 info.connection_status_description = |
| 863 UTF16ToUTF8(site_connection_details_); | 802 UTF16ToUTF8(site_connection_details_); |
| 864 info.identity_status = site_identity_status_; | 803 info.identity_status = site_identity_status_; |
| 865 info.identity_status_description = | 804 info.identity_status_description = |
| 866 UTF16ToUTF8(site_identity_details_); | 805 UTF16ToUTF8(site_identity_details_); |
| 867 info.certificate = certificate_; | 806 info.certificate = certificate_; |
| 868 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_; | 807 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_; |
| 869 ui_->SetIdentityInfo(info); | 808 ui_->SetIdentityInfo(info); |
| 870 } | 809 } |
| OLD | NEW |