| 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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 } else if (net::IsCertStatusMinorError(security_info.cert_status)) { | 436 } else if (net::IsCertStatusMinorError(security_info.cert_status)) { |
| 491 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN; | 437 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN; |
| 492 base::string16 issuer_name( | 438 base::string16 issuer_name( |
| 493 UTF8ToUTF16(certificate_->issuer().GetDisplayName())); | 439 UTF8ToUTF16(certificate_->issuer().GetDisplayName())); |
| 494 if (issuer_name.empty()) { | 440 if (issuer_name.empty()) { |
| 495 issuer_name.assign(l10n_util::GetStringUTF16( | 441 issuer_name.assign(l10n_util::GetStringUTF16( |
| 496 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); | 442 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); |
| 497 } | 443 } |
| 498 | 444 |
| 499 site_identity_details_.assign(l10n_util::GetStringFUTF16( | 445 site_identity_details_.assign(l10n_util::GetStringFUTF16( |
| 500 GetSiteIdentityDetailsMessageByCTInfo( | 446 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name)); |
| 501 security_info.sct_verify_statuses, false /* not EV */), | |
| 502 issuer_name)); | |
| 503 | 447 |
| 504 site_identity_details_ += ASCIIToUTF16("\n\n"); | 448 site_identity_details_ += ASCIIToUTF16("\n\n"); |
| 505 if (security_info.cert_status & | 449 if (security_info.cert_status & |
| 506 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) { | 450 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) { |
| 507 site_identity_details_ += l10n_util::GetStringUTF16( | 451 site_identity_details_ += l10n_util::GetStringUTF16( |
| 508 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION); | 452 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION); |
| 509 } else if (security_info.cert_status & | 453 } else if (security_info.cert_status & |
| 510 net::CERT_STATUS_NO_REVOCATION_MECHANISM) { | 454 net::CERT_STATUS_NO_REVOCATION_MECHANISM) { |
| 511 site_identity_details_ += l10n_util::GetStringUTF16( | 455 site_identity_details_ += l10n_util::GetStringUTF16( |
| 512 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM); | 456 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM); |
| 513 } else { | 457 } else { |
| 514 NOTREACHED() << "Need to specify string for this warning"; | 458 NOTREACHED() << "Need to specify string for this warning"; |
| 515 } | 459 } |
| 516 } else { | 460 } else { |
| 461 // No major or minor errors. |
| 517 if (security_info.cert_status & net::CERT_STATUS_IS_EV) { | 462 if (security_info.cert_status & net::CERT_STATUS_IS_EV) { |
| 518 // EV HTTPS page. | 463 // EV HTTPS page. |
| 519 site_identity_status_ = GetSiteIdentityStatusByCTInfo( | 464 site_identity_status_ = SITE_IDENTITY_STATUS_EV_CERT; |
| 520 security_info.sct_verify_statuses, true); | |
| 521 DCHECK(!certificate_->subject().organization_names.empty()); | 465 DCHECK(!certificate_->subject().organization_names.empty()); |
| 522 organization_name_ = | 466 organization_name_ = |
| 523 UTF8ToUTF16(certificate_->subject().organization_names[0]); | 467 UTF8ToUTF16(certificate_->subject().organization_names[0]); |
| 524 // An EV Cert is required to have a city (localityName) and country but | 468 // An EV Cert is required to have a city (localityName) and country but |
| 525 // state is "if any". | 469 // state is "if any". |
| 526 DCHECK(!certificate_->subject().locality_name.empty()); | 470 DCHECK(!certificate_->subject().locality_name.empty()); |
| 527 DCHECK(!certificate_->subject().country_name.empty()); | 471 DCHECK(!certificate_->subject().country_name.empty()); |
| 528 base::string16 locality; | 472 base::string16 locality; |
| 529 if (!certificate_->subject().state_or_province_name.empty()) { | 473 if (!certificate_->subject().state_or_province_name.empty()) { |
| 530 locality = l10n_util::GetStringFUTF16( | 474 locality = l10n_util::GetStringFUTF16( |
| 531 IDS_PAGEINFO_ADDRESS, | 475 IDS_PAGEINFO_ADDRESS, |
| 532 UTF8ToUTF16(certificate_->subject().locality_name), | 476 UTF8ToUTF16(certificate_->subject().locality_name), |
| 533 UTF8ToUTF16(certificate_->subject().state_or_province_name), | 477 UTF8ToUTF16(certificate_->subject().state_or_province_name), |
| 534 UTF8ToUTF16(certificate_->subject().country_name)); | 478 UTF8ToUTF16(certificate_->subject().country_name)); |
| 535 } else { | 479 } else { |
| 536 locality = l10n_util::GetStringFUTF16( | 480 locality = l10n_util::GetStringFUTF16( |
| 537 IDS_PAGEINFO_PARTIAL_ADDRESS, | 481 IDS_PAGEINFO_PARTIAL_ADDRESS, |
| 538 UTF8ToUTF16(certificate_->subject().locality_name), | 482 UTF8ToUTF16(certificate_->subject().locality_name), |
| 539 UTF8ToUTF16(certificate_->subject().country_name)); | 483 UTF8ToUTF16(certificate_->subject().country_name)); |
| 540 } | 484 } |
| 541 DCHECK(!certificate_->subject().organization_names.empty()); | 485 DCHECK(!certificate_->subject().organization_names.empty()); |
| 542 site_identity_details_.assign(l10n_util::GetStringFUTF16( | 486 site_identity_details_.assign(l10n_util::GetStringFUTF16( |
| 543 GetSiteIdentityDetailsMessageByCTInfo( | 487 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]), | 488 UTF8ToUTF16(certificate_->subject().organization_names[0]), |
| 546 locality, | 489 locality, UTF8ToUTF16(certificate_->issuer().GetDisplayName()))); |
| 547 UTF8ToUTF16(certificate_->issuer().GetDisplayName()))); | |
| 548 } else { | 490 } else { |
| 549 // Non-EV OK HTTPS page. | 491 // Non-EV OK HTTPS page. |
| 550 site_identity_status_ = GetSiteIdentityStatusByCTInfo( | 492 site_identity_status_ = SITE_IDENTITY_STATUS_CERT; |
| 551 security_info.sct_verify_statuses, false); | |
| 552 base::string16 issuer_name( | 493 base::string16 issuer_name( |
| 553 UTF8ToUTF16(certificate_->issuer().GetDisplayName())); | 494 UTF8ToUTF16(certificate_->issuer().GetDisplayName())); |
| 554 if (issuer_name.empty()) { | 495 if (issuer_name.empty()) { |
| 555 issuer_name.assign(l10n_util::GetStringUTF16( | 496 issuer_name.assign(l10n_util::GetStringUTF16( |
| 556 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); | 497 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); |
| 557 } | 498 } |
| 558 | 499 |
| 559 site_identity_details_.assign(l10n_util::GetStringFUTF16( | 500 site_identity_details_.assign(l10n_util::GetStringFUTF16( |
| 560 GetSiteIdentityDetailsMessageByCTInfo( | 501 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name)); |
| 561 security_info.sct_verify_statuses, false /* not EV */), | |
| 562 issuer_name)); | |
| 563 } | 502 } |
| 564 switch (security_info.sha1_deprecation_status) { | 503 switch (security_info.sha1_deprecation_status) { |
| 565 case SecurityStateModel::DEPRECATED_SHA1_MINOR: | 504 case SecurityStateModel::DEPRECATED_SHA1_MINOR: |
| 566 site_identity_status_ = | 505 site_identity_status_ = |
| 567 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR; | 506 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR; |
| 568 site_identity_details_ += | 507 site_identity_details_ += |
| 569 UTF8ToUTF16("\n\n") + | 508 UTF8ToUTF16("\n\n") + |
| 570 l10n_util::GetStringUTF16( | 509 l10n_util::GetStringUTF16( |
| 571 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM_MINO
R); | 510 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM_MINO
R); |
| 572 break; | 511 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 | 681 // 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 | 682 // it was loaded over an unencrypted connection, don't select the Connection |
| 744 // Tab. | 683 // Tab. |
| 745 WebsiteSettingsUI::TabId tab_id = WebsiteSettingsUI::TAB_ID_PERMISSIONS; | 684 WebsiteSettingsUI::TabId tab_id = WebsiteSettingsUI::TAB_ID_PERMISSIONS; |
| 746 if (site_connection_status_ == SITE_CONNECTION_STATUS_ENCRYPTED_ERROR || | 685 if (site_connection_status_ == SITE_CONNECTION_STATUS_ENCRYPTED_ERROR || |
| 747 site_connection_status_ == | 686 site_connection_status_ == |
| 748 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE || | 687 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE || |
| 749 site_connection_status_ == | 688 site_connection_status_ == |
| 750 SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE || | 689 SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE || |
| 751 site_identity_status_ == SITE_IDENTITY_STATUS_ERROR || | 690 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 || | 691 site_identity_status_ == SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN || |
| 754 site_identity_status_ == SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT || | 692 site_identity_status_ == SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT || |
| 755 site_identity_status_ == | 693 site_identity_status_ == |
| 756 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR || | 694 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR || |
| 757 site_identity_status_ == | 695 site_identity_status_ == |
| 758 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR) { | 696 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR) { |
| 759 tab_id = WebsiteSettingsUI::TAB_ID_CONNECTION; | 697 tab_id = WebsiteSettingsUI::TAB_ID_CONNECTION; |
| 760 RecordWebsiteSettingsAction( | 698 RecordWebsiteSettingsAction( |
| 761 WEBSITE_SETTINGS_CONNECTION_TAB_SHOWN_IMMEDIATELY); | 699 WEBSITE_SETTINGS_CONNECTION_TAB_SHOWN_IMMEDIATELY); |
| 762 } | 700 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 info.connection_status = site_connection_status_; | 799 info.connection_status = site_connection_status_; |
| 862 info.connection_status_description = | 800 info.connection_status_description = |
| 863 UTF16ToUTF8(site_connection_details_); | 801 UTF16ToUTF8(site_connection_details_); |
| 864 info.identity_status = site_identity_status_; | 802 info.identity_status = site_identity_status_; |
| 865 info.identity_status_description = | 803 info.identity_status_description = |
| 866 UTF16ToUTF8(site_identity_details_); | 804 UTF16ToUTF8(site_identity_details_); |
| 867 info.certificate = certificate_; | 805 info.certificate = certificate_; |
| 868 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_; | 806 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_; |
| 869 ui_->SetIdentityInfo(info); | 807 ui_->SetIdentityInfo(info); |
| 870 } | 808 } |
| OLD | NEW |