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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 std::vector<uint8_t> SSLClientSocket::SerializeNextProtos( | 191 std::vector<uint8_t> SSLClientSocket::SerializeNextProtos( |
192 const NextProtoVector& next_protos, | 192 const NextProtoVector& next_protos) { |
193 bool can_advertise_http2) { | |
194 std::vector<uint8_t> wire_protos; | 193 std::vector<uint8_t> wire_protos; |
195 for (const NextProto next_proto : next_protos) { | 194 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); | 195 const std::string proto = NextProtoToString(next_proto); |
200 if (proto.size() > 255) { | 196 if (proto.size() > 255) { |
201 LOG(WARNING) << "Ignoring overlong NPN/ALPN protocol: " << proto; | 197 LOG(WARNING) << "Ignoring overlong NPN/ALPN protocol: " << proto; |
202 continue; | 198 continue; |
203 } | 199 } |
204 if (proto.size() == 0) { | 200 if (proto.size() == 0) { |
205 LOG(WARNING) << "Ignoring empty NPN/ALPN protocol"; | 201 LOG(WARNING) << "Ignoring empty NPN/ALPN protocol"; |
206 continue; | 202 continue; |
207 } | 203 } |
208 wire_protos.push_back(proto.size()); | 204 wire_protos.push_back(proto.size()); |
209 for (const char ch : proto) { | 205 for (const char ch : proto) { |
210 wire_protos.push_back(static_cast<uint8_t>(ch)); | 206 wire_protos.push_back(static_cast<uint8_t>(ch)); |
211 } | 207 } |
212 } | 208 } |
213 | 209 |
214 return wire_protos; | 210 return wire_protos; |
215 } | 211 } |
216 | 212 |
217 } // namespace net | 213 } // namespace net |
OLD | NEW |