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

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: Update function call in test. 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
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::IsSecurityAdequateForHTTP2(
239 const SSLConfig& ssl_config,
240 const std::vector<uint16>& cipher_suites) {
241 if (ssl_config.version_max < SSL_PROTOCOL_VERSION_TLS1_2)
242 return false;
243 for (uint16 cipher : cipher_suites) {
244 if (IsSecureTLSCipherSuite(cipher))
245 return true;
246 }
247 return false;
248 }
249
250 // static
237 std::vector<uint8_t> SSLClientSocket::SerializeNextProtos( 251 std::vector<uint8_t> SSLClientSocket::SerializeNextProtos(
238 const NextProtoVector& next_protos) { 252 const NextProtoVector& next_protos,
253 bool can_advertise_http2) {
239 std::vector<uint8_t> wire_protos; 254 std::vector<uint8_t> wire_protos;
240 for (const NextProto next_proto : next_protos) { 255 for (const NextProto next_proto : next_protos) {
256 if (!can_advertise_http2 && kProtoSPDY4MinimumVersion <= next_proto &&
257 next_proto <= kProtoSPDY4MaximumVersion) {
258 continue;
259 }
241 const std::string proto = NextProtoToString(next_proto); 260 const std::string proto = NextProtoToString(next_proto);
242 if (proto.size() > 255) { 261 if (proto.size() > 255) {
243 LOG(WARNING) << "Ignoring overlong NPN/ALPN protocol: " << proto; 262 LOG(WARNING) << "Ignoring overlong NPN/ALPN protocol: " << proto;
244 continue; 263 continue;
245 } 264 }
246 if (proto.size() == 0) { 265 if (proto.size() == 0) {
247 LOG(WARNING) << "Ignoring empty NPN/ALPN protocol"; 266 LOG(WARNING) << "Ignoring empty NPN/ALPN protocol";
248 continue; 267 continue;
249 } 268 }
250 wire_protos.push_back(proto.size()); 269 wire_protos.push_back(proto.size());
(...skipping 25 matching lines...) Expand all
276 } else { 295 } else {
277 sample += 500; 296 sample += 500;
278 } 297 }
279 } else { 298 } else {
280 DCHECK_EQ(kExtensionALPN, negotiation_extension_); 299 DCHECK_EQ(kExtensionALPN, negotiation_extension_);
281 } 300 }
282 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSLProtocolNegotiation", sample); 301 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSLProtocolNegotiation", sample);
283 } 302 }
284 303
285 } // namespace net 304 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698