Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_ssl_host_state_delegate.h" | 5 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 // canonicalizes all hosts into a secure scheme GURL to use with content | 65 // canonicalizes all hosts into a secure scheme GURL to use with content |
| 66 // settings. The returned GURL will be the passed in host with an empty path and | 66 // settings. The returned GURL will be the passed in host with an empty path and |
| 67 // https:// as the scheme. | 67 // https:// as the scheme. |
| 68 GURL GetSecureGURLForHost(const std::string& host) { | 68 GURL GetSecureGURLForHost(const std::string& host) { |
| 69 std::string url = "https://" + host; | 69 std::string url = "https://" + host; |
| 70 return GURL(url); | 70 return GURL(url); |
| 71 } | 71 } |
| 72 | 72 |
| 73 // This is a helper function that returns the length of time before a | 73 // This is a helper function that returns the length of time before a |
| 74 // certificate decision expires based on the command line flags. Returns a | 74 // certificate decision expires based on the command line flags. Returns a |
| 75 // non-negative value in seconds or a value of -1 indicating that decisions | 75 // non-negative value in seconds or a value of -1 indicating that decisions |
|
willchan no longer on Chromium
2014/08/20 22:17:21
unnecessary extra horizontal whitespace after the
jww
2014/08/22 00:54:16
Done.
| |
| 76 // should not be remembered after the current session has ended (but should be | 76 // should not be remembered after the current session has ended (but should be |
| 77 // remembered indefinitely as long as the session does not end), which is the | 77 // remembered indefinitely as long as the session does not end), which is the |
| 78 // "old" style of certificate decision memory. Uses the experimental group | 78 // "old" style of certificate decision memory. Uses the experimental group |
| 79 // unless overridden by a command line flag. | 79 // unless overridden by a command line flag. |
| 80 int64 GetExpirationDelta() { | 80 int64 GetExpirationDelta() { |
| 81 // Check command line flags first to give them priority, then check | 81 // Check command line flags first to give them priority, then check |
| 82 // experimental groups. | 82 // experimental groups. |
| 83 if (CommandLine::ForCurrentProcess()->HasSwitch( | 83 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 84 switches::kRememberCertErrorDecisions)) { | 84 switches::kRememberCertErrorDecisions)) { |
| 85 std::string switch_value = | 85 std::string switch_value = |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 } | 119 } |
| 120 | 120 |
| 121 std::string GetKey(net::X509Certificate* cert, net::CertStatus error) { | 121 std::string GetKey(net::X509Certificate* cert, net::CertStatus error) { |
| 122 // Since a security decision will be made based on the fingerprint, Chrome | 122 // Since a security decision will be made based on the fingerprint, Chrome |
| 123 // should use the SHA-256 fingerprint for the certificate. | 123 // should use the SHA-256 fingerprint for the certificate. |
| 124 net::SHA256HashValue fingerprint = | 124 net::SHA256HashValue fingerprint = |
| 125 net::X509Certificate::CalculateChainFingerprint256( | 125 net::X509Certificate::CalculateChainFingerprint256( |
| 126 cert->os_cert_handle(), cert->GetIntermediateCertificates()); | 126 cert->os_cert_handle(), cert->GetIntermediateCertificates()); |
| 127 std::string base64_fingerprint; | 127 std::string base64_fingerprint; |
| 128 base::Base64Encode( | 128 base::Base64Encode( |
| 129 base::StringPiece(reinterpret_cast<const char*>(fingerprint.data), | 129 base::StringPiece(reinterpret_cast<const char*>(fingerprint.data), |
|
willchan no longer on Chromium
2014/08/20 22:17:21
Is this reinterpret_cast<> necessary? Shouldn't th
jww
2014/08/22 00:54:16
I was surprised, too, but Clang complains about "n
| |
| 130 sizeof(fingerprint.data)), | 130 sizeof(fingerprint.data)), |
| 131 &base64_fingerprint); | 131 &base64_fingerprint); |
| 132 return base::UintToString(error) + base64_fingerprint; | 132 return base::UintToString(error) + base64_fingerprint; |
| 133 } | 133 } |
| 134 | 134 |
| 135 } // namespace | 135 } // namespace |
| 136 | 136 |
| 137 // This helper function gets the dictionary of certificate fingerprints to | 137 // This helper function gets the dictionary of certificate fingerprints to |
| 138 // errors of certificates that have been accepted by the user from the content | 138 // errors of certificates that have been accepted by the user from the content |
| 139 // dictionary that has been passed in. The returned pointer is owned by the the | 139 // dictionary that has been passed in. The returned pointer is owned by the the |
| 140 // argument dict that is passed in. | 140 // argument dict that is passed in. |
| 141 // | 141 // |
| 142 // If create_entries is set to |DoNotCreateDictionaryEntries|, | 142 // If create_entries is set to |DoNotCreateDictionaryEntries|, |
| 143 // GetValidCertDecisionsDict will return NULL if there is anything invalid about | 143 // GetValidCertDecisionsDict will return NULL if there is anything invalid about |
| 144 // the setting, such as an invalid version or invalid value types (in addition | 144 // the setting, such as an invalid version or invalid value types (in addition |
| 145 // to there not be any values in the dictionary). If create_entries is set to | 145 // to there not be any values in the dictionary). If create_entries is set to |
|
willchan no longer on Chromium
2014/08/20 22:17:21
grammar is off here...perhaps s/be/being/?
jww
2014/08/22 00:54:17
Done.
| |
| 146 // |CreateDictionaryEntries|, if no dictionary is found or the decisions are | 146 // |CreateDictionaryEntries|, if no dictionary is found or the decisions are |
| 147 // expired, a new dictionary will be created | 147 // expired, a new dictionary will be created |
|
willchan no longer on Chromium
2014/08/20 22:17:21
Missing '.' at the end.
jww
2014/08/22 00:54:16
Done.
| |
| 148 base::DictionaryValue* ChromeSSLHostStateDelegate::GetValidCertDecisionsDict( | 148 base::DictionaryValue* ChromeSSLHostStateDelegate::GetValidCertDecisionsDict( |
|
willchan no longer on Chromium
2014/08/20 22:17:21
You should directly include "base/values.h" for th
jww
2014/08/22 00:54:16
Done.
| |
| 149 base::DictionaryValue* dict, | 149 base::DictionaryValue* dict, |
|
willchan no longer on Chromium
2014/08/20 22:17:21
Not for readability, and don't worry, the length o
jww
2014/08/22 00:54:16
It sounds like we might want to change this but in
| |
| 150 CreateDictionaryEntriesDisposition create_entries, | 150 CreateDictionaryEntriesDisposition create_entries, |
| 151 bool* expired_previous_decision) { | 151 bool* expired_previous_decision) { |
| 152 // This needs to be done first in case the method is short circuited by an | 152 // This needs to be done first in case the method is short circuited by an |
| 153 // early failure. | 153 // early failure. |
| 154 *expired_previous_decision = false; | 154 *expired_previous_decision = false; |
| 155 | 155 |
| 156 // Extract the version of the certificate decision structure from the content | 156 // Extract the version of the certificate decision structure from the content |
| 157 // setting. | 157 // setting. |
| 158 int version; | 158 int version; |
| 159 bool success = dict->GetInteger(kSSLCertDecisionVersionKey, &version); | 159 bool success = dict->GetInteger(kSSLCertDecisionVersionKey, &version); |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 434 cert_dict->SetIntegerWithoutPathExpansion(GetKey(cert, error), judgment); | 434 cert_dict->SetIntegerWithoutPathExpansion(GetKey(cert, error), judgment); |
| 435 | 435 |
| 436 // The map takes ownership of the value, so it is released in the call to | 436 // The map takes ownership of the value, so it is released in the call to |
| 437 // SetWebsiteSetting. | 437 // SetWebsiteSetting. |
| 438 map->SetWebsiteSetting(pattern, | 438 map->SetWebsiteSetting(pattern, |
| 439 pattern, | 439 pattern, |
| 440 CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, | 440 CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, |
| 441 std::string(), | 441 std::string(), |
| 442 value.release()); | 442 value.release()); |
| 443 } | 443 } |
| 444 | |
| OLD | NEW |