| 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_macros.h" | 7 #include "base/metrics/histogram_macros.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" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 return false; | 181 return false; |
| 182 } | 182 } |
| 183 | 183 |
| 184 // static | 184 // static |
| 185 bool SSLClientSocket::IsTLSVersionAdequateForHTTP2( | 185 bool SSLClientSocket::IsTLSVersionAdequateForHTTP2( |
| 186 const SSLConfig& ssl_config) { | 186 const SSLConfig& ssl_config) { |
| 187 return ssl_config.version_max >= SSL_PROTOCOL_VERSION_TLS1_2; | 187 return ssl_config.version_max >= SSL_PROTOCOL_VERSION_TLS1_2; |
| 188 } | 188 } |
| 189 | 189 |
| 190 // static | 190 // static |
| 191 void SSLClientSocket::DisableHTTP2(NextProtoVector* next_protos) { |
| 192 for (NextProtoVector::iterator it = next_protos->begin(); |
| 193 it != next_protos->end();) { |
| 194 if (*it == kProtoHTTP2) { |
| 195 it = next_protos->erase(it); |
| 196 continue; |
| 197 } |
| 198 ++it; |
| 199 } |
| 200 } |
| 201 |
| 202 // static |
| 191 std::vector<uint8_t> SSLClientSocket::SerializeNextProtos( | 203 std::vector<uint8_t> SSLClientSocket::SerializeNextProtos( |
| 192 const NextProtoVector& next_protos, | 204 const NextProtoVector& next_protos) { |
| 193 bool can_advertise_http2) { | |
| 194 std::vector<uint8_t> wire_protos; | 205 std::vector<uint8_t> wire_protos; |
| 195 for (const NextProto next_proto : next_protos) { | 206 for (const NextProto next_proto : next_protos) { |
| 196 if (!can_advertise_http2 && next_proto == kProtoHTTP2) { | |
| 197 continue; | |
| 198 } | |
| 199 const std::string proto = NextProtoToString(next_proto); | 207 const std::string proto = NextProtoToString(next_proto); |
| 200 if (proto.size() > 255) { | 208 if (proto.size() > 255) { |
| 201 LOG(WARNING) << "Ignoring overlong NPN/ALPN protocol: " << proto; | 209 LOG(WARNING) << "Ignoring overlong NPN/ALPN protocol: " << proto; |
| 202 continue; | 210 continue; |
| 203 } | 211 } |
| 204 if (proto.size() == 0) { | 212 if (proto.size() == 0) { |
| 205 LOG(WARNING) << "Ignoring empty NPN/ALPN protocol"; | 213 LOG(WARNING) << "Ignoring empty NPN/ALPN protocol"; |
| 206 continue; | 214 continue; |
| 207 } | 215 } |
| 208 wire_protos.push_back(proto.size()); | 216 wire_protos.push_back(proto.size()); |
| 209 for (const char ch : proto) { | 217 for (const char ch : proto) { |
| 210 wire_protos.push_back(static_cast<uint8_t>(ch)); | 218 wire_protos.push_back(static_cast<uint8_t>(ch)); |
| 211 } | 219 } |
| 212 } | 220 } |
| 213 | 221 |
| 214 return wire_protos; | 222 return wire_protos; |
| 215 } | 223 } |
| 216 | 224 |
| 217 } // namespace net | 225 } // namespace net |
| OLD | NEW |