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_impl.h" | 5 #include "net/socket/ssl_client_socket_impl.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <openssl/bio.h> | 8 #include <openssl/bio.h> |
9 #include <openssl/bytestring.h> | 9 #include <openssl/bytestring.h> |
10 #include <openssl/err.h> | 10 #include <openssl/err.h> |
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 SSL_get0_alpn_selected(ssl_, &alpn_proto, &alpn_len); | 1208 SSL_get0_alpn_selected(ssl_, &alpn_proto, &alpn_len); |
1209 if (alpn_len > 0) { | 1209 if (alpn_len > 0) { |
1210 base::StringPiece proto(reinterpret_cast<const char*>(alpn_proto), | 1210 base::StringPiece proto(reinterpret_cast<const char*>(alpn_proto), |
1211 alpn_len); | 1211 alpn_len); |
1212 negotiated_protocol_ = NextProtoFromString(proto); | 1212 negotiated_protocol_ = NextProtoFromString(proto); |
1213 npn_status_ = kNextProtoNegotiated; | 1213 npn_status_ = kNextProtoNegotiated; |
1214 negotiation_extension_ = kExtensionALPN; | 1214 negotiation_extension_ = kExtensionALPN; |
1215 } | 1215 } |
1216 } | 1216 } |
1217 | 1217 |
1218 RecordNegotiationExtension(); | 1218 RecordNegotiatedProtocol(); |
1219 RecordChannelIDSupport(); | 1219 RecordChannelIDSupport(); |
1220 | 1220 |
1221 const uint8_t* ocsp_response_raw; | 1221 const uint8_t* ocsp_response_raw; |
1222 size_t ocsp_response_len; | 1222 size_t ocsp_response_len; |
1223 SSL_get0_ocsp_response(ssl_, &ocsp_response_raw, &ocsp_response_len); | 1223 SSL_get0_ocsp_response(ssl_, &ocsp_response_raw, &ocsp_response_len); |
1224 std::string ocsp_response; | 1224 std::string ocsp_response; |
1225 if (ocsp_response_len > 0) { | 1225 if (ocsp_response_len > 0) { |
1226 ocsp_response_.assign(reinterpret_cast<const char*>(ocsp_response_raw), | 1226 ocsp_response_.assign(reinterpret_cast<const char*>(ocsp_response_raw), |
1227 ocsp_response_len); | 1227 ocsp_response_len); |
1228 } | 1228 } |
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2331 void SSLClientSocketImpl::LogConnectEndEvent(int rv) { | 2331 void SSLClientSocketImpl::LogConnectEndEvent(int rv) { |
2332 if (rv != OK) { | 2332 if (rv != OK) { |
2333 net_log_.EndEventWithNetErrorCode(NetLogEventType::SSL_CONNECT, rv); | 2333 net_log_.EndEventWithNetErrorCode(NetLogEventType::SSL_CONNECT, rv); |
2334 return; | 2334 return; |
2335 } | 2335 } |
2336 | 2336 |
2337 net_log_.EndEvent(NetLogEventType::SSL_CONNECT, | 2337 net_log_.EndEvent(NetLogEventType::SSL_CONNECT, |
2338 base::Bind(&NetLogSSLInfoCallback, base::Unretained(this))); | 2338 base::Bind(&NetLogSSLInfoCallback, base::Unretained(this))); |
2339 } | 2339 } |
2340 | 2340 |
2341 void SSLClientSocketImpl::RecordNegotiationExtension() const { | 2341 void SSLClientSocketImpl::RecordNegotiatedProtocol() const { |
2342 if (negotiation_extension_ == kExtensionUnknown) | 2342 UMA_HISTOGRAM_ENUMERATION("Net.SSLNegotiatedAlpnProtocol", |
2343 return; | 2343 negotiated_protocol_, kProtoLast + 1); |
2344 if (npn_status_ == kNextProtoUnsupported) | |
2345 return; | |
2346 base::HistogramBase::Sample sample = | |
2347 static_cast<base::HistogramBase::Sample>(negotiated_protocol_); | |
2348 // In addition to the protocol negotiated, we want to record which TLS | |
2349 // extension was used, and in case of NPN, whether there was overlap between | |
2350 // server and client list of supported protocols. | |
2351 if (negotiation_extension_ == kExtensionNPN) { | |
2352 if (npn_status_ == kNextProtoNoOverlap) { | |
2353 sample += 1000; | |
2354 } else { | |
2355 sample += 500; | |
2356 } | |
2357 } else { | |
2358 DCHECK_EQ(kExtensionALPN, negotiation_extension_); | |
2359 } | |
2360 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSLProtocolNegotiation", sample); | |
2361 } | 2344 } |
2362 | 2345 |
2363 void SSLClientSocketImpl::RecordChannelIDSupport() const { | 2346 void SSLClientSocketImpl::RecordChannelIDSupport() const { |
2364 // Since this enum is used for a histogram, do not change or re-use values. | 2347 // Since this enum is used for a histogram, do not change or re-use values. |
2365 enum { | 2348 enum { |
2366 DISABLED = 0, | 2349 DISABLED = 0, |
2367 CLIENT_ONLY = 1, | 2350 CLIENT_ONLY = 1, |
2368 CLIENT_AND_SERVER = 2, | 2351 CLIENT_AND_SERVER = 2, |
2369 // CLIENT_NO_ECC is unused now. | 2352 // CLIENT_NO_ECC is unused now. |
2370 // CLIENT_BAD_SYSTEM_TIME is unused now. | 2353 // CLIENT_BAD_SYSTEM_TIME is unused now. |
(...skipping 11 matching lines...) Expand all Loading... |
2382 } | 2365 } |
2383 UMA_HISTOGRAM_ENUMERATION("DomainBoundCerts.Support", supported, | 2366 UMA_HISTOGRAM_ENUMERATION("DomainBoundCerts.Support", supported, |
2384 CHANNEL_ID_USAGE_MAX); | 2367 CHANNEL_ID_USAGE_MAX); |
2385 } | 2368 } |
2386 | 2369 |
2387 bool SSLClientSocketImpl::IsChannelIDEnabled() const { | 2370 bool SSLClientSocketImpl::IsChannelIDEnabled() const { |
2388 return ssl_config_.channel_id_enabled && channel_id_service_; | 2371 return ssl_config_.channel_id_enabled && channel_id_service_; |
2389 } | 2372 } |
2390 | 2373 |
2391 } // namespace net | 2374 } // namespace net |
OLD | NEW |