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/feature_list.h" | |
7 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
8 #include "base/metrics/sparse_histogram.h" | 9 #include "base/metrics/sparse_histogram.h" |
9 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "build/build_config.h" | |
10 #include "crypto/ec_private_key.h" | 12 #include "crypto/ec_private_key.h" |
11 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
12 #include "net/socket/ssl_client_socket_impl.h" | 14 #include "net/socket/ssl_client_socket_impl.h" |
13 #include "net/ssl/channel_id_service.h" | 15 #include "net/ssl/channel_id_service.h" |
14 #include "net/ssl/ssl_config_service.h" | 16 #include "net/ssl/ssl_config_service.h" |
15 | 17 |
16 namespace net { | 18 namespace net { |
17 | 19 |
20 namespace { | |
21 #if !defined(OS_NACL) | |
22 const base::Feature kPostQuantumExperiment{"SSLPostQuantumExperiment", | |
jwd
2016/08/01 15:53:53
We tend not to like features including "experiment
mab
2016/08/09 21:04:41
OK, leaving alone. Would you have called it "SSLP
jwd
2016/08/10 17:39:26
Probably SSLPostQuantum, but I might have gone wit
| |
23 base::FEATURE_DISABLED_BY_DEFAULT}; | |
24 #endif | |
25 | |
26 } // namespace | |
27 | |
18 SSLClientSocket::SSLClientSocket() | 28 SSLClientSocket::SSLClientSocket() |
19 : signed_cert_timestamps_received_(false), | 29 : signed_cert_timestamps_received_(false), |
20 stapled_ocsp_response_received_(false), | 30 stapled_ocsp_response_received_(false), |
21 negotiation_extension_(kExtensionUnknown) { | 31 negotiation_extension_(kExtensionUnknown) { |
22 } | 32 } |
23 | 33 |
24 // static | 34 // static |
25 NextProto SSLClientSocket::NextProtoFromString( | 35 NextProto SSLClientSocket::NextProtoFromString( |
26 const std::string& proto_string) { | 36 const std::string& proto_string) { |
27 if (proto_string == "http1.1" || proto_string == "http/1.1") { | 37 if (proto_string == "http1.1" || proto_string == "http/1.1") { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 return NextProtoFromString(proto); | 101 return NextProtoFromString(proto); |
92 } | 102 } |
93 | 103 |
94 bool SSLClientSocket::IgnoreCertError(int error, int load_flags) { | 104 bool SSLClientSocket::IgnoreCertError(int error, int load_flags) { |
95 if (error == OK) | 105 if (error == OK) |
96 return true; | 106 return true; |
97 return (load_flags & LOAD_IGNORE_ALL_CERT_ERRORS) && | 107 return (load_flags & LOAD_IGNORE_ALL_CERT_ERRORS) && |
98 IsCertificateError(error); | 108 IsCertificateError(error); |
99 } | 109 } |
100 | 110 |
111 // static | |
112 bool SSLClientSocket::IsPostQuantumExperimentEnabled() { | |
113 #if !defined(OS_NACL) | |
114 return base::FeatureList::IsEnabled(kPostQuantumExperiment); | |
115 #endif | |
116 return false; | |
117 } | |
118 | |
101 void SSLClientSocket::RecordNegotiationExtension() { | 119 void SSLClientSocket::RecordNegotiationExtension() { |
102 if (negotiation_extension_ == kExtensionUnknown) | 120 if (negotiation_extension_ == kExtensionUnknown) |
103 return; | 121 return; |
104 std::string proto; | 122 std::string proto; |
105 SSLClientSocket::NextProtoStatus status = GetNextProto(&proto); | 123 SSLClientSocket::NextProtoStatus status = GetNextProto(&proto); |
106 if (status == kNextProtoUnsupported) | 124 if (status == kNextProtoUnsupported) |
107 return; | 125 return; |
108 // Convert protocol into numerical value for histogram. | 126 // Convert protocol into numerical value for histogram. |
109 NextProto protocol_negotiated = SSLClientSocket::NextProtoFromString(proto); | 127 NextProto protocol_negotiated = SSLClientSocket::NextProtoFromString(proto); |
110 base::HistogramBase::Sample sample = | 128 base::HistogramBase::Sample sample = |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 wire_protos.push_back(proto.size()); | 194 wire_protos.push_back(proto.size()); |
177 for (const char ch : proto) { | 195 for (const char ch : proto) { |
178 wire_protos.push_back(static_cast<uint8_t>(ch)); | 196 wire_protos.push_back(static_cast<uint8_t>(ch)); |
179 } | 197 } |
180 } | 198 } |
181 | 199 |
182 return wire_protos; | 200 return wire_protos; |
183 } | 201 } |
184 | 202 |
185 } // namespace net | 203 } // namespace net |
OLD | NEW |