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