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

Side by Side Diff: net/socket/ssl_client_socket_impl.cc

Issue 2625883002: SSLClientSessionCache: Log number of times Lookup is called per Session. (Closed)
Patch Set: reply to comments Created 3 years, 11 months 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_impl.h" 5 #include "net/socket/ssl_client_socket_impl.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 // 6066, Section 3). 938 // 6066, Section 3).
939 // 939 //
940 // TODO(rsleevi): Should this code allow hostnames that violate the LDH rule? 940 // TODO(rsleevi): Should this code allow hostnames that violate the LDH rule?
941 // See https://crbug.com/496472 and https://crbug.com/496468 for discussion. 941 // See https://crbug.com/496472 and https://crbug.com/496468 for discussion.
942 IPAddress unused; 942 IPAddress unused;
943 if (!unused.AssignFromIPLiteral(host_and_port_.host()) && 943 if (!unused.AssignFromIPLiteral(host_and_port_.host()) &&
944 !SSL_set_tlsext_host_name(ssl_.get(), host_and_port_.host().c_str())) { 944 !SSL_set_tlsext_host_name(ssl_.get(), host_and_port_.host().c_str())) {
945 return ERR_UNEXPECTED; 945 return ERR_UNEXPECTED;
946 } 946 }
947 947
948 bssl::UniquePtr<SSL_SESSION> session = 948 bssl::UniquePtr<SSL_SESSION> session = context->session_cache()->Lookup(
949 context->session_cache()->Lookup(GetSessionCacheKey()); 949 GetSessionCacheKey(), &ssl_session_cache_lookup_count_);
950 if (session) 950 if (session)
951 SSL_set_session(ssl_.get(), session.get()); 951 SSL_set_session(ssl_.get(), session.get());
952 952
953 transport_adapter_.reset(new SocketBIOAdapter( 953 transport_adapter_.reset(new SocketBIOAdapter(
954 transport_->socket(), GetBufferSize("SSLBufferSizeRecv"), 954 transport_->socket(), GetBufferSize("SSLBufferSizeRecv"),
955 GetBufferSize("SSLBufferSizeSend"), this)); 955 GetBufferSize("SSLBufferSizeSend"), this));
956 BIO* transport_bio = transport_adapter_->bio(); 956 BIO* transport_bio = transport_adapter_->bio();
957 957
958 BIO_up_ref(transport_bio); // SSL_set0_rbio takes ownership. 958 BIO_up_ref(transport_bio); // SSL_set0_rbio takes ownership.
959 SSL_set0_rbio(ssl_.get(), transport_bio); 959 SSL_set0_rbio(ssl_.get(), transport_bio);
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 } 1140 }
1141 1141
1142 next_handshake_state_ = STATE_HANDSHAKE_COMPLETE; 1142 next_handshake_state_ = STATE_HANDSHAKE_COMPLETE;
1143 return net_error; 1143 return net_error;
1144 } 1144 }
1145 1145
1146 int SSLClientSocketImpl::DoHandshakeComplete(int result) { 1146 int SSLClientSocketImpl::DoHandshakeComplete(int result) {
1147 if (result < 0) 1147 if (result < 0)
1148 return result; 1148 return result;
1149 1149
1150 SSLContext::GetInstance()->session_cache()->ResetLookupCount(
1151 GetSessionCacheKey());
1152 // If we got a session from the session cache, log how many concurrent
1153 // handshakes that session was used in before we finished our handshake. This
1154 // is only recorded if the session from the cache was actually used, and only
1155 // if the ALPN protocol is h2 (under the assumption that TLS 1.3 servers will
1156 // be speaking h2).
davidben 2017/01/19 21:56:12 Nit: Probably link to the bug here too, so it's cl
nharper 2017/01/19 22:09:07 Done.
1157 if (ssl_session_cache_lookup_count_ && negotiated_protocol_ == kProtoHTTP2 &&
1158 SSL_session_reused(ssl_.get())) {
1159 UMA_HISTOGRAM_EXACT_LINEAR("Net.SSLSessionConcurrentLookupCount",
1160 ssl_session_cache_lookup_count_, 20);
1161 }
1162
1150 // DHE is offered on the deprecated cipher fallback and then rejected 1163 // DHE is offered on the deprecated cipher fallback and then rejected
1151 // afterwards. This is to aid in diagnosing connection failures because a 1164 // afterwards. This is to aid in diagnosing connection failures because a
1152 // server requires DHE ciphers. 1165 // server requires DHE ciphers.
1153 // 1166 //
1154 // TODO(davidben): A few releases after DHE's removal, remove this logic. 1167 // TODO(davidben): A few releases after DHE's removal, remove this logic.
1155 if (!ssl_config_.dhe_enabled && 1168 if (!ssl_config_.dhe_enabled &&
1156 SSL_CIPHER_is_DHE(SSL_get_current_cipher(ssl_.get()))) { 1169 SSL_CIPHER_is_DHE(SSL_get_current_cipher(ssl_.get()))) {
1157 return ERR_SSL_OBSOLETE_CIPHER; 1170 return ERR_SSL_OBSOLETE_CIPHER;
1158 } 1171 }
1159 1172
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
2048 if (ERR_GET_REASON(info->error_code) == SSL_R_TLSV1_ALERT_ACCESS_DENIED && 2061 if (ERR_GET_REASON(info->error_code) == SSL_R_TLSV1_ALERT_ACCESS_DENIED &&
2049 !certificate_requested_) { 2062 !certificate_requested_) {
2050 net_error = ERR_SSL_PROTOCOL_ERROR; 2063 net_error = ERR_SSL_PROTOCOL_ERROR;
2051 } 2064 }
2052 } 2065 }
2053 2066
2054 return net_error; 2067 return net_error;
2055 } 2068 }
2056 2069
2057 } // namespace net 2070 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698