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 "net/socket/ssl_client_socket.h" | 5 #include "net/socket/ssl_client_socket.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "crypto/ec_private_key.h" | 9 #include "crypto/ec_private_key.h" |
10 #include "net/ssl/server_bound_cert_service.h" | 10 #include "net/ssl/server_bound_cert_service.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 } | 79 } |
80 return NULL; | 80 return NULL; |
81 } | 81 } |
82 | 82 |
83 // static | 83 // static |
84 std::string SSLClientSocket::ServerProtosToString( | 84 std::string SSLClientSocket::ServerProtosToString( |
85 const std::string& server_protos) { | 85 const std::string& server_protos) { |
86 const char* protos = server_protos.c_str(); | 86 const char* protos = server_protos.c_str(); |
87 size_t protos_len = server_protos.length(); | 87 size_t protos_len = server_protos.length(); |
88 std::vector<std::string> server_protos_with_commas; | 88 std::vector<std::string> server_protos_with_commas; |
89 for (size_t i = 0; i < protos_len; ) { | 89 for (size_t i = 0; i < protos_len;) { |
90 const size_t len = protos[i]; | 90 const size_t len = protos[i]; |
91 std::string proto_str(&protos[i + 1], len); | 91 std::string proto_str(&protos[i + 1], len); |
92 server_protos_with_commas.push_back(proto_str); | 92 server_protos_with_commas.push_back(proto_str); |
93 i += len + 1; | 93 i += len + 1; |
94 } | 94 } |
95 return JoinString(server_protos_with_commas, ','); | 95 return JoinString(server_protos_with_commas, ','); |
96 } | 96 } |
97 | 97 |
98 bool SSLClientSocket::WasNpnNegotiated() const { | 98 bool SSLClientSocket::WasNpnNegotiated() const { |
99 return was_npn_negotiated_; | 99 return was_npn_negotiated_; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 } else if (channel_id_enabled) { | 177 } else if (channel_id_enabled) { |
178 if (!server_bound_cert_service) | 178 if (!server_bound_cert_service) |
179 supported = CLIENT_NO_SERVER_BOUND_CERT_SERVICE; | 179 supported = CLIENT_NO_SERVER_BOUND_CERT_SERVICE; |
180 else if (!supports_ecc) | 180 else if (!supports_ecc) |
181 supported = CLIENT_NO_ECC; | 181 supported = CLIENT_NO_ECC; |
182 else if (!server_bound_cert_service->IsSystemTimeValid()) | 182 else if (!server_bound_cert_service->IsSystemTimeValid()) |
183 supported = CLIENT_BAD_SYSTEM_TIME; | 183 supported = CLIENT_BAD_SYSTEM_TIME; |
184 else | 184 else |
185 supported = CLIENT_ONLY; | 185 supported = CLIENT_ONLY; |
186 } | 186 } |
187 UMA_HISTOGRAM_ENUMERATION("DomainBoundCerts.Support", supported, | 187 UMA_HISTOGRAM_ENUMERATION( |
188 DOMAIN_BOUND_CERT_USAGE_MAX); | 188 "DomainBoundCerts.Support", supported, DOMAIN_BOUND_CERT_USAGE_MAX); |
189 } | 189 } |
190 | 190 |
191 // static | 191 // static |
192 bool SSLClientSocket::IsChannelIDEnabled( | 192 bool SSLClientSocket::IsChannelIDEnabled( |
193 const SSLConfig& ssl_config, | 193 const SSLConfig& ssl_config, |
194 ServerBoundCertService* server_bound_cert_service) { | 194 ServerBoundCertService* server_bound_cert_service) { |
195 if (!ssl_config.channel_id_enabled) | 195 if (!ssl_config.channel_id_enabled) |
196 return false; | 196 return false; |
197 if (!server_bound_cert_service) { | 197 if (!server_bound_cert_service) { |
198 DVLOG(1) << "NULL server_bound_cert_service_, not enabling channel ID."; | 198 DVLOG(1) << "NULL server_bound_cert_service_, not enabling channel ID."; |
199 return false; | 199 return false; |
200 } | 200 } |
201 if (!crypto::ECPrivateKey::IsSupported()) { | 201 if (!crypto::ECPrivateKey::IsSupported()) { |
202 DVLOG(1) << "Elliptic Curve not supported, not enabling channel ID."; | 202 DVLOG(1) << "Elliptic Curve not supported, not enabling channel ID."; |
203 return false; | 203 return false; |
204 } | 204 } |
205 if (!server_bound_cert_service->IsSystemTimeValid()) { | 205 if (!server_bound_cert_service->IsSystemTimeValid()) { |
206 DVLOG(1) << "System time is not within the supported range for certificate " | 206 DVLOG(1) << "System time is not within the supported range for certificate " |
207 "generation, not enabling channel ID."; | 207 "generation, not enabling channel ID."; |
208 return false; | 208 return false; |
209 } | 209 } |
210 return true; | 210 return true; |
211 } | 211 } |
212 | 212 |
213 } // namespace net | 213 } // namespace net |
OLD | NEW |