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

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

Issue 787913003: Instrumenting SSL_do_handshake and UpdateServerCert to find jank (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // OpenSSL binding for SSLClientSocket. The class layout and general principle 5 // OpenSSL binding for SSLClientSocket. The class layout and general principle
6 // of operation is derived from SSLClientSocketNSS. 6 // of operation is derived from SSLClientSocketNSS.
7 7
8 #include "net/socket/ssl_client_socket_openssl.h" 8 #include "net/socket/ssl_client_socket_openssl.h"
9 9
10 #include <errno.h> 10 #include <errno.h>
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 rv = BufferSend(); 911 rv = BufferSend();
912 if (rv != ERR_IO_PENDING && rv != 0) 912 if (rv != ERR_IO_PENDING && rv != 0)
913 network_moved = true; 913 network_moved = true;
914 } while (rv > 0); 914 } while (rv > 0);
915 if (transport_read_error_ == OK && BufferRecv() != ERR_IO_PENDING) 915 if (transport_read_error_ == OK && BufferRecv() != ERR_IO_PENDING)
916 network_moved = true; 916 network_moved = true;
917 return network_moved; 917 return network_moved;
918 } 918 }
919 919
920 int SSLClientSocketOpenSSL::DoHandshake() { 920 int SSLClientSocketOpenSSL::DoHandshake() {
921 // TODO(vadimt): Remove ScopedTracker below once crbug.com/424386 is fixed.
922 tracked_objects::ScopedTracker tracking_profile1(
923 FROM_HERE_WITH_EXPLICIT_FUNCTION(
924 "424386 SSLClientSocketOpenSSL::DoHandshake1"));
925
926 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); 921 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE);
927 int net_error = OK; 922 int net_error = OK;
928 int rv = SSL_do_handshake(ssl_); 923
924 int rv;
925
926 // TODO(vadimt): is_first_handshake and leave only 1 call to SSL_do_handshake
927 // once crbug.com/424386 is fixed.
928 static bool is_first_handshake = true;
Ryan Sleevi 2014/12/23 00:12:30 Not LGTM. SSLClientSocketOpenSSL can be used from
vadimt 2014/12/23 00:56:13 Done. The logic behind the reworked implementatio
929 if (is_first_handshake) {
930 // TODO(vadimt): Remove ScopedTracker below once crbug.com/424386 is fixed.
931 tracked_objects::ScopedTracker tracking_profile1_1(
932 FROM_HERE_WITH_EXPLICIT_FUNCTION(
933 "424386 SSLClientSocketOpenSSL::DoHandshake1_2"));
934
935 is_first_handshake = false;
936 rv = SSL_do_handshake(ssl_);
937 } else {
938 // TODO(vadimt): Remove ScopedTracker below once crbug.com/424386 is fixed.
939 tracked_objects::ScopedTracker tracking_profile1_2(
940 FROM_HERE_WITH_EXPLICIT_FUNCTION(
941 "424386 SSLClientSocketOpenSSL::DoHandshake1_2"));
942
943 rv = SSL_do_handshake(ssl_);
944 }
929 945
930 if (client_auth_cert_needed_) { 946 if (client_auth_cert_needed_) {
931 // TODO(vadimt): Remove ScopedTracker below once crbug.com/424386 is fixed. 947 // TODO(vadimt): Remove ScopedTracker below once crbug.com/424386 is fixed.
932 tracked_objects::ScopedTracker tracking_profile2( 948 tracked_objects::ScopedTracker tracking_profile2(
933 FROM_HERE_WITH_EXPLICIT_FUNCTION( 949 FROM_HERE_WITH_EXPLICIT_FUNCTION(
934 "424386 SSLClientSocketOpenSSL::DoHandshake2")); 950 "424386 SSLClientSocketOpenSSL::DoHandshake2"));
935 951
936 net_error = ERR_SSL_CLIENT_AUTH_CERT_NEEDED; 952 net_error = ERR_SSL_CLIENT_AUTH_CERT_NEEDED;
937 // If the handshake already succeeded (because the server requests but 953 // If the handshake already succeeded (because the server requests but
938 // doesn't require a client cert), we need to invalidate the SSL session 954 // doesn't require a client cert), we need to invalidate the SSL session
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 } 1225 }
1210 } 1226 }
1211 1227
1212 void SSLClientSocketOpenSSL::UpdateServerCert() { 1228 void SSLClientSocketOpenSSL::UpdateServerCert() {
1213 // TODO(vadimt): Remove ScopedTracker below once crbug.com/424386 is fixed. 1229 // TODO(vadimt): Remove ScopedTracker below once crbug.com/424386 is fixed.
1214 tracked_objects::ScopedTracker tracking_profile( 1230 tracked_objects::ScopedTracker tracking_profile(
1215 FROM_HERE_WITH_EXPLICIT_FUNCTION( 1231 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1216 "424386 SSLClientSocketOpenSSL::UpdateServerCert")); 1232 "424386 SSLClientSocketOpenSSL::UpdateServerCert"));
1217 1233
1218 server_cert_chain_->Reset(SSL_get_peer_cert_chain(ssl_)); 1234 server_cert_chain_->Reset(SSL_get_peer_cert_chain(ssl_));
1235
1236 // TODO(vadimt): Remove ScopedTracker below once crbug.com/424386 is fixed.
1237 tracked_objects::ScopedTracker tracking_profile1(
1238 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1239 "424386 SSLClientSocketOpenSSL::UpdateServerCert1"));
1219 server_cert_ = server_cert_chain_->AsOSChain(); 1240 server_cert_ = server_cert_chain_->AsOSChain();
1220 1241
1221 if (server_cert_.get()) { 1242 if (server_cert_.get()) {
1222 net_log_.AddEvent( 1243 net_log_.AddEvent(
1223 NetLog::TYPE_SSL_CERTIFICATES_RECEIVED, 1244 NetLog::TYPE_SSL_CERTIFICATES_RECEIVED,
1224 base::Bind(&NetLogX509CertificateCallback, 1245 base::Bind(&NetLogX509CertificateCallback,
1225 base::Unretained(server_cert_.get()))); 1246 base::Unretained(server_cert_.get())));
1226 1247
1227 // TODO(rsleevi): Plumb an OCSP response into the Mac system library and 1248 // TODO(rsleevi): Plumb an OCSP response into the Mac system library and
1228 // update IsOCSPStaplingSupported for Mac. https://crbug.com/430714 1249 // update IsOCSPStaplingSupported for Mac. https://crbug.com/430714
1229 if (IsOCSPStaplingSupported()) { 1250 if (IsOCSPStaplingSupported()) {
1230 #if defined(OS_WIN) 1251 #if defined(OS_WIN)
1252 // TODO(vadimt): Remove ScopedTracker below once crbug.com/424386 is
1253 // fixed.
1254 tracked_objects::ScopedTracker tracking_profile2(
1255 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1256 "424386 SSLClientSocketOpenSSL::UpdateServerCert2"));
1257
1231 const uint8_t* ocsp_response_raw; 1258 const uint8_t* ocsp_response_raw;
1232 size_t ocsp_response_len; 1259 size_t ocsp_response_len;
1233 SSL_get0_ocsp_response(ssl_, &ocsp_response_raw, &ocsp_response_len); 1260 SSL_get0_ocsp_response(ssl_, &ocsp_response_raw, &ocsp_response_len);
1234 1261
1235 CRYPT_DATA_BLOB ocsp_response_blob; 1262 CRYPT_DATA_BLOB ocsp_response_blob;
1236 ocsp_response_blob.cbData = ocsp_response_len; 1263 ocsp_response_blob.cbData = ocsp_response_len;
1237 ocsp_response_blob.pbData = const_cast<BYTE*>(ocsp_response_raw); 1264 ocsp_response_blob.pbData = const_cast<BYTE*>(ocsp_response_raw);
1238 BOOL ok = CertSetCertificateContextProperty( 1265 BOOL ok = CertSetCertificateContextProperty(
1239 server_cert_->os_cert_handle(), 1266 server_cert_->os_cert_handle(),
1240 CERT_OCSP_RESPONSE_PROP_ID, 1267 CERT_OCSP_RESPONSE_PROP_ID,
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
1948 ct::SCT_STATUS_LOG_UNKNOWN)); 1975 ct::SCT_STATUS_LOG_UNKNOWN));
1949 } 1976 }
1950 } 1977 }
1951 1978
1952 scoped_refptr<X509Certificate> 1979 scoped_refptr<X509Certificate>
1953 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { 1980 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const {
1954 return server_cert_; 1981 return server_cert_;
1955 } 1982 }
1956 1983
1957 } // namespace net 1984 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698