| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/chrome_security_state_model_client.h" | 5 #include "chrome/browser/ssl/chrome_security_state_model_client.h" |
| 6 | 6 |
| 7 #include <openssl/ssl.h> |
| 8 |
| 7 #include <vector> | 9 #include <vector> |
| 8 | 10 |
| 9 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 10 #include "base/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
| 11 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 12 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 14 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 15 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/chromeos/policy/policy_cert_service.h" | 18 #include "chrome/browser/chromeos/policy/policy_cert_service.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 NOTREACHED(); | 87 NOTREACHED(); |
| 86 return content::SECURITY_STYLE_UNKNOWN; | 88 return content::SECURITY_STYLE_UNKNOWN; |
| 87 } | 89 } |
| 88 | 90 |
| 89 void AddConnectionExplanation( | 91 void AddConnectionExplanation( |
| 90 const security_state::SecurityStateModel::SecurityInfo& security_info, | 92 const security_state::SecurityStateModel::SecurityInfo& security_info, |
| 91 content::SecurityStyleExplanations* security_style_explanations) { | 93 content::SecurityStyleExplanations* security_style_explanations) { |
| 92 | 94 |
| 93 // Avoid showing TLS details when we couldn't even establish a TLS connection | 95 // Avoid showing TLS details when we couldn't even establish a TLS connection |
| 94 // (e.g. for net errors) or if there was no real connection (some tests). We | 96 // (e.g. for net errors) or if there was no real connection (some tests). We |
| 95 // check the |cert_id| to see if there was a connection. | 97 // check the |connection_status| to see if there was a connection. |
| 96 if (security_info.cert_id == 0 || security_info.connection_status == 0) { | 98 if (security_info.connection_status == 0) { |
| 97 return; | 99 return; |
| 98 } | 100 } |
| 99 | 101 |
| 100 int ssl_version = | 102 int ssl_version = |
| 101 net::SSLConnectionStatusToVersion(security_info.connection_status); | 103 net::SSLConnectionStatusToVersion(security_info.connection_status); |
| 102 const char* protocol; | 104 const char* protocol; |
| 103 net::SSLVersionToString(&protocol, ssl_version); | 105 net::SSLVersionToString(&protocol, ssl_version); |
| 104 const char* key_exchange; | 106 const char* key_exchange; |
| 105 const char* cipher; | 107 const char* cipher; |
| 106 const char* mac; | 108 const char* mac; |
| 107 bool is_aead; | 109 bool is_aead; |
| 108 uint16_t cipher_suite = | 110 uint16_t cipher_suite = |
| 109 net::SSLConnectionStatusToCipherSuite(security_info.connection_status); | 111 net::SSLConnectionStatusToCipherSuite(security_info.connection_status); |
| 110 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead, | 112 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead, |
| 111 cipher_suite); | 113 cipher_suite); |
| 112 base::string16 protocol_name = base::ASCIIToUTF16(protocol); | 114 base::string16 protocol_name = base::ASCIIToUTF16(protocol); |
| 113 base::string16 key_exchange_name = base::ASCIIToUTF16(key_exchange); | 115 base::string16 key_exchange_name = base::ASCIIToUTF16(key_exchange); |
| 114 const base::string16 cipher_name = | 116 const base::string16 cipher_name = |
| 115 (mac == NULL) ? base::ASCIIToUTF16(cipher) | 117 (mac == NULL) ? base::ASCIIToUTF16(cipher) |
| 116 : l10n_util::GetStringFUTF16(IDS_CIPHER_WITH_MAC, | 118 : l10n_util::GetStringFUTF16(IDS_CIPHER_WITH_MAC, |
| 117 base::ASCIIToUTF16(cipher), | 119 base::ASCIIToUTF16(cipher), |
| 118 base::ASCIIToUTF16(mac)); | 120 base::ASCIIToUTF16(mac)); |
| 121 |
| 122 // Include the key exchange group (previously known as curve) if specified. |
| 123 // |
| 124 // TODO(davidben): When TLS 1.3's new negotiation is implemented, omit the |
| 125 // "key exchange" if empty and only display the group, which is the true key |
| 126 // exchange. See https://crbug.com/639495. |
| 127 if (security_info.key_exchange_group != 0) { |
| 128 key_exchange_name = l10n_util::GetStringFUTF16( |
| 129 IDS_SSL_KEY_EXCHANGE_WITH_GROUP, key_exchange_name, |
| 130 base::ASCIIToUTF16( |
| 131 SSL_get_curve_name(security_info.key_exchange_group))); |
| 132 } |
| 133 |
| 119 if (security_info.obsolete_ssl_status == net::OBSOLETE_SSL_NONE) { | 134 if (security_info.obsolete_ssl_status == net::OBSOLETE_SSL_NONE) { |
| 120 security_style_explanations->secure_explanations.push_back( | 135 security_style_explanations->secure_explanations.push_back( |
| 121 content::SecurityStyleExplanation( | 136 content::SecurityStyleExplanation( |
| 122 l10n_util::GetStringUTF8(IDS_STRONG_SSL_SUMMARY), | 137 l10n_util::GetStringUTF8(IDS_STRONG_SSL_SUMMARY), |
| 123 l10n_util::GetStringFUTF8(IDS_STRONG_SSL_DESCRIPTION, protocol_name, | 138 l10n_util::GetStringFUTF8(IDS_STRONG_SSL_DESCRIPTION, protocol_name, |
| 124 key_exchange_name, cipher_name))); | 139 key_exchange_name, cipher_name))); |
| 125 return; | 140 return; |
| 126 } | 141 } |
| 127 | 142 |
| 128 std::vector<base::string16> description_replacements; | 143 std::vector<base::string16> description_replacements; |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 } | 368 } |
| 354 | 369 |
| 355 state->connection_info_initialized = true; | 370 state->connection_info_initialized = true; |
| 356 state->url = entry->GetURL(); | 371 state->url = entry->GetURL(); |
| 357 const content::SSLStatus& ssl = entry->GetSSL(); | 372 const content::SSLStatus& ssl = entry->GetSSL(); |
| 358 state->initial_security_level = | 373 state->initial_security_level = |
| 359 GetSecurityLevelForSecurityStyle(ssl.security_style); | 374 GetSecurityLevelForSecurityStyle(ssl.security_style); |
| 360 state->cert_id = ssl.cert_id; | 375 state->cert_id = ssl.cert_id; |
| 361 state->cert_status = ssl.cert_status; | 376 state->cert_status = ssl.cert_status; |
| 362 state->connection_status = ssl.connection_status; | 377 state->connection_status = ssl.connection_status; |
| 378 state->key_exchange_group = ssl.key_exchange_group; |
| 363 state->security_bits = ssl.security_bits; | 379 state->security_bits = ssl.security_bits; |
| 364 state->pkp_bypassed = ssl.pkp_bypassed; | 380 state->pkp_bypassed = ssl.pkp_bypassed; |
| 365 state->sct_verify_statuses.clear(); | 381 state->sct_verify_statuses.clear(); |
| 366 state->sct_verify_statuses.insert(state->sct_verify_statuses.begin(), | 382 state->sct_verify_statuses.insert(state->sct_verify_statuses.begin(), |
| 367 ssl.sct_statuses.begin(), | 383 ssl.sct_statuses.begin(), |
| 368 ssl.sct_statuses.end()); | 384 ssl.sct_statuses.end()); |
| 369 state->displayed_mixed_content = | 385 state->displayed_mixed_content = |
| 370 !!(ssl.content_status & content::SSLStatus::DISPLAYED_INSECURE_CONTENT); | 386 !!(ssl.content_status & content::SSLStatus::DISPLAYED_INSECURE_CONTENT); |
| 371 state->ran_mixed_content = | 387 state->ran_mixed_content = |
| 372 !!(ssl.content_status & content::SSLStatus::RAN_INSECURE_CONTENT); | 388 !!(ssl.content_status & content::SSLStatus::RAN_INSECURE_CONTENT); |
| 373 state->displayed_content_with_cert_errors = | 389 state->displayed_content_with_cert_errors = |
| 374 !!(ssl.content_status & | 390 !!(ssl.content_status & |
| 375 content::SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS); | 391 content::SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS); |
| 376 state->ran_content_with_cert_errors = | 392 state->ran_content_with_cert_errors = |
| 377 !!(ssl.content_status & content::SSLStatus::RAN_CONTENT_WITH_CERT_ERRORS); | 393 !!(ssl.content_status & content::SSLStatus::RAN_CONTENT_WITH_CERT_ERRORS); |
| 378 | 394 |
| 379 CheckSafeBrowsingStatus(entry, web_contents_, state); | 395 CheckSafeBrowsingStatus(entry, web_contents_, state); |
| 380 } | 396 } |
| OLD | NEW |