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

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: Fixing a type Created 5 years, 12 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
« 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 base::subtle::Atomic32 is_first_handshake =
929 1; // 0 is false, 1 is true.
930 if (base::subtle::NoBarrier_Load(&is_first_handshake)) {
931 // TODO(vadimt): Remove ScopedTracker below once crbug.com/424386 is fixed.
932 tracked_objects::ScopedTracker tracking_profile1_1(
933 FROM_HERE_WITH_EXPLICIT_FUNCTION(
934 "424386 SSLClientSocketOpenSSL::DoHandshake1_1"));
935
936 rv = SSL_do_handshake(ssl_);
937 base::subtle::NoBarrier_Store(&is_first_handshake, 0);
938 } else {
939 // TODO(vadimt): Remove ScopedTracker below once crbug.com/424386 is fixed.
940 tracked_objects::ScopedTracker tracking_profile1_2(
941 FROM_HERE_WITH_EXPLICIT_FUNCTION(
942 "424386 SSLClientSocketOpenSSL::DoHandshake1_2"));
943
944 rv = SSL_do_handshake(ssl_);
945 }
Ryan Sleevi 2014/12/23 01:11:25 Still Not LGTM. The argument you make for coalesc
Ryan Sleevi 2014/12/23 03:28:14 Something like if (ssl_config_.send_client_cert &&
929 946
930 if (client_auth_cert_needed_) { 947 if (client_auth_cert_needed_) {
931 // TODO(vadimt): Remove ScopedTracker below once crbug.com/424386 is fixed. 948 // TODO(vadimt): Remove ScopedTracker below once crbug.com/424386 is fixed.
932 tracked_objects::ScopedTracker tracking_profile2( 949 tracked_objects::ScopedTracker tracking_profile2(
933 FROM_HERE_WITH_EXPLICIT_FUNCTION( 950 FROM_HERE_WITH_EXPLICIT_FUNCTION(
934 "424386 SSLClientSocketOpenSSL::DoHandshake2")); 951 "424386 SSLClientSocketOpenSSL::DoHandshake2"));
935 952
936 net_error = ERR_SSL_CLIENT_AUTH_CERT_NEEDED; 953 net_error = ERR_SSL_CLIENT_AUTH_CERT_NEEDED;
937 // If the handshake already succeeded (because the server requests but 954 // If the handshake already succeeded (because the server requests but
938 // doesn't require a client cert), we need to invalidate the SSL session 955 // 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 } 1226 }
1210 } 1227 }
1211 1228
1212 void SSLClientSocketOpenSSL::UpdateServerCert() { 1229 void SSLClientSocketOpenSSL::UpdateServerCert() {
1213 // TODO(vadimt): Remove ScopedTracker below once crbug.com/424386 is fixed. 1230 // TODO(vadimt): Remove ScopedTracker below once crbug.com/424386 is fixed.
1214 tracked_objects::ScopedTracker tracking_profile( 1231 tracked_objects::ScopedTracker tracking_profile(
1215 FROM_HERE_WITH_EXPLICIT_FUNCTION( 1232 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1216 "424386 SSLClientSocketOpenSSL::UpdateServerCert")); 1233 "424386 SSLClientSocketOpenSSL::UpdateServerCert"));
1217 1234
1218 server_cert_chain_->Reset(SSL_get_peer_cert_chain(ssl_)); 1235 server_cert_chain_->Reset(SSL_get_peer_cert_chain(ssl_));
1236
1237 // TODO(vadimt): Remove ScopedTracker below once crbug.com/424386 is fixed.
1238 tracked_objects::ScopedTracker tracking_profile1(
1239 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1240 "424386 SSLClientSocketOpenSSL::UpdateServerCert1"));
1219 server_cert_ = server_cert_chain_->AsOSChain(); 1241 server_cert_ = server_cert_chain_->AsOSChain();
1220 1242
1221 if (server_cert_.get()) { 1243 if (server_cert_.get()) {
1222 net_log_.AddEvent( 1244 net_log_.AddEvent(
1223 NetLog::TYPE_SSL_CERTIFICATES_RECEIVED, 1245 NetLog::TYPE_SSL_CERTIFICATES_RECEIVED,
1224 base::Bind(&NetLogX509CertificateCallback, 1246 base::Bind(&NetLogX509CertificateCallback,
1225 base::Unretained(server_cert_.get()))); 1247 base::Unretained(server_cert_.get())));
1226 1248
1227 // TODO(rsleevi): Plumb an OCSP response into the Mac system library and 1249 // TODO(rsleevi): Plumb an OCSP response into the Mac system library and
1228 // update IsOCSPStaplingSupported for Mac. https://crbug.com/430714 1250 // update IsOCSPStaplingSupported for Mac. https://crbug.com/430714
1229 if (IsOCSPStaplingSupported()) { 1251 if (IsOCSPStaplingSupported()) {
1230 #if defined(OS_WIN) 1252 #if defined(OS_WIN)
1253 // TODO(vadimt): Remove ScopedTracker below once crbug.com/424386 is
1254 // fixed.
1255 tracked_objects::ScopedTracker tracking_profile2(
1256 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1257 "424386 SSLClientSocketOpenSSL::UpdateServerCert2"));
1258
1231 const uint8_t* ocsp_response_raw; 1259 const uint8_t* ocsp_response_raw;
1232 size_t ocsp_response_len; 1260 size_t ocsp_response_len;
1233 SSL_get0_ocsp_response(ssl_, &ocsp_response_raw, &ocsp_response_len); 1261 SSL_get0_ocsp_response(ssl_, &ocsp_response_raw, &ocsp_response_len);
1234 1262
1235 CRYPT_DATA_BLOB ocsp_response_blob; 1263 CRYPT_DATA_BLOB ocsp_response_blob;
1236 ocsp_response_blob.cbData = ocsp_response_len; 1264 ocsp_response_blob.cbData = ocsp_response_len;
1237 ocsp_response_blob.pbData = const_cast<BYTE*>(ocsp_response_raw); 1265 ocsp_response_blob.pbData = const_cast<BYTE*>(ocsp_response_raw);
1238 BOOL ok = CertSetCertificateContextProperty( 1266 BOOL ok = CertSetCertificateContextProperty(
1239 server_cert_->os_cert_handle(), 1267 server_cert_->os_cert_handle(),
1240 CERT_OCSP_RESPONSE_PROP_ID, 1268 CERT_OCSP_RESPONSE_PROP_ID,
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
1948 ct::SCT_STATUS_LOG_UNKNOWN)); 1976 ct::SCT_STATUS_LOG_UNKNOWN));
1949 } 1977 }
1950 } 1978 }
1951 1979
1952 scoped_refptr<X509Certificate> 1980 scoped_refptr<X509Certificate>
1953 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { 1981 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const {
1954 return server_cert_; 1982 return server_cert_;
1955 } 1983 }
1956 1984
1957 } // namespace net 1985 } // 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