Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: net/socket/ssl_client_socket.cc

Issue 757033004: Do not use HTTP/2 without adequate security. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove incorrect comment. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/socket/ssl_client_socket.h ('k') | net/socket/ssl_client_socket_nss.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/metrics/sparse_histogram.h" 8 #include "base/metrics/sparse_histogram.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "crypto/ec_private_key.h" 10 #include "crypto/ec_private_key.h"
11 #include "net/base/connection_type_histograms.h" 11 #include "net/base/connection_type_histograms.h"
12 #include "net/base/host_port_pair.h" 12 #include "net/base/host_port_pair.h"
13 #include "net/ssl/channel_id_service.h" 13 #include "net/ssl/channel_id_service.h"
14 #include "net/ssl/ssl_cipher_suite_names.h"
14 #include "net/ssl/ssl_config_service.h" 15 #include "net/ssl/ssl_config_service.h"
15 #include "net/ssl/ssl_connection_status_flags.h" 16 #include "net/ssl/ssl_connection_status_flags.h"
16 17
17 namespace net { 18 namespace net {
18 19
19 SSLClientSocket::SSLClientSocket() 20 SSLClientSocket::SSLClientSocket()
20 : was_npn_negotiated_(false), 21 : was_npn_negotiated_(false),
21 was_spdy_negotiated_(false), 22 was_spdy_negotiated_(false),
22 protocol_negotiated_(kProtoUnknown), 23 protocol_negotiated_(kProtoUnknown),
23 channel_id_sent_(false), 24 channel_id_sent_(false),
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 } 228 }
228 if (!channel_id_service->IsSystemTimeValid()) { 229 if (!channel_id_service->IsSystemTimeValid()) {
229 DVLOG(1) << "System time is not within the supported range for certificate " 230 DVLOG(1) << "System time is not within the supported range for certificate "
230 "generation, not enabling channel ID."; 231 "generation, not enabling channel ID.";
231 return false; 232 return false;
232 } 233 }
233 return true; 234 return true;
234 } 235 }
235 236
236 // static 237 // static
238 bool SSLClientSocket::HasCipherAdequateForHTTP2(
239 const std::vector<uint16>& cipher_suites) {
240 for (uint16 cipher : cipher_suites) {
241 if (IsSecureTLSCipherSuite(cipher))
242 return true;
243 }
244 return false;
245 }
246
247 // static
248 bool SSLClientSocket::IsTLSVersionAdequateForHTTP2(
249 const SSLConfig& ssl_config) {
250 return ssl_config.version_max >= SSL_PROTOCOL_VERSION_TLS1_2;
251 }
252
253 // static
237 std::vector<uint8_t> SSLClientSocket::SerializeNextProtos( 254 std::vector<uint8_t> SSLClientSocket::SerializeNextProtos(
238 const NextProtoVector& next_protos) { 255 const NextProtoVector& next_protos,
256 bool can_advertise_http2) {
239 std::vector<uint8_t> wire_protos; 257 std::vector<uint8_t> wire_protos;
240 for (const NextProto next_proto : next_protos) { 258 for (const NextProto next_proto : next_protos) {
259 if (!can_advertise_http2 && kProtoSPDY4MinimumVersion <= next_proto &&
260 next_proto <= kProtoSPDY4MaximumVersion) {
261 continue;
262 }
241 const std::string proto = NextProtoToString(next_proto); 263 const std::string proto = NextProtoToString(next_proto);
242 if (proto.size() > 255) { 264 if (proto.size() > 255) {
243 LOG(WARNING) << "Ignoring overlong NPN/ALPN protocol: " << proto; 265 LOG(WARNING) << "Ignoring overlong NPN/ALPN protocol: " << proto;
244 continue; 266 continue;
245 } 267 }
246 if (proto.size() == 0) { 268 if (proto.size() == 0) {
247 LOG(WARNING) << "Ignoring empty NPN/ALPN protocol"; 269 LOG(WARNING) << "Ignoring empty NPN/ALPN protocol";
248 continue; 270 continue;
249 } 271 }
250 wire_protos.push_back(proto.size()); 272 wire_protos.push_back(proto.size());
(...skipping 25 matching lines...) Expand all
276 } else { 298 } else {
277 sample += 500; 299 sample += 500;
278 } 300 }
279 } else { 301 } else {
280 DCHECK_EQ(kExtensionALPN, negotiation_extension_); 302 DCHECK_EQ(kExtensionALPN, negotiation_extension_);
281 } 303 }
282 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSLProtocolNegotiation", sample); 304 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSLProtocolNegotiation", sample);
283 } 305 }
284 306
285 } // namespace net 307 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_client_socket.h ('k') | net/socket/ssl_client_socket_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698