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

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

Issue 494913002: Include better OpenSSL error information in NetLog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
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>
11 #include <openssl/err.h> 11 #include <openssl/err.h>
12 #include <openssl/ssl.h> 12 #include <openssl/ssl.h>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/callback_helpers.h" 15 #include "base/callback_helpers.h"
16 #include "base/memory/singleton.h" 16 #include "base/memory/singleton.h"
17 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
18 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
19 #include "crypto/ec_private_key.h" 19 #include "crypto/ec_private_key.h"
20 #include "crypto/openssl_util.h" 20 #include "crypto/openssl_util.h"
21 #include "crypto/scoped_openssl_types.h" 21 #include "crypto/scoped_openssl_types.h"
22 #include "net/base/net_errors.h" 22 #include "net/base/net_errors.h"
23 #include "net/cert/cert_verifier.h" 23 #include "net/cert/cert_verifier.h"
24 #include "net/cert/single_request_cert_verifier.h" 24 #include "net/cert/single_request_cert_verifier.h"
25 #include "net/cert/x509_certificate_net_log_param.h" 25 #include "net/cert/x509_certificate_net_log_param.h"
26 #include "net/http/transport_security_state.h" 26 #include "net/http/transport_security_state.h"
27 #include "net/socket/ssl_error_params.h"
28 #include "net/socket/ssl_session_cache_openssl.h" 27 #include "net/socket/ssl_session_cache_openssl.h"
29 #include "net/ssl/openssl_ssl_util.h" 28 #include "net/ssl/openssl_ssl_util.h"
30 #include "net/ssl/ssl_cert_request_info.h" 29 #include "net/ssl/ssl_cert_request_info.h"
31 #include "net/ssl/ssl_connection_status_flags.h" 30 #include "net/ssl/ssl_connection_status_flags.h"
32 #include "net/ssl/ssl_info.h" 31 #include "net/ssl/ssl_info.h"
33 32
34 #if defined(USE_OPENSSL_CERTS) 33 #if defined(USE_OPENSSL_CERTS)
35 #include "net/ssl/openssl_client_key_store.h" 34 #include "net/ssl/openssl_client_key_store.h"
36 #else 35 #else
37 #include "net/ssl/openssl_platform_key.h" 36 #include "net/ssl/openssl_platform_key.h"
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 int ssl_error = SSL_get_error(ssl_, rv); 901 int ssl_error = SSL_get_error(ssl_, rv);
903 902
904 if (ssl_error == SSL_ERROR_WANT_CHANNEL_ID_LOOKUP) { 903 if (ssl_error == SSL_ERROR_WANT_CHANNEL_ID_LOOKUP) {
905 // The server supports channel ID. Stop to look one up before returning to 904 // The server supports channel ID. Stop to look one up before returning to
906 // the handshake. 905 // the handshake.
907 channel_id_xtn_negotiated_ = true; 906 channel_id_xtn_negotiated_ = true;
908 GotoState(STATE_CHANNEL_ID_LOOKUP); 907 GotoState(STATE_CHANNEL_ID_LOOKUP);
909 return OK; 908 return OK;
910 } 909 }
911 910
912 net_error = MapOpenSSLError(ssl_error, err_tracer); 911 uint32_t error_code;
912 const char* file;
913 int line;
914 net_error = MapOpenSSLErrorWithDetails(
915 ssl_error, err_tracer, &error_code, &file, &line);
Ryan Sleevi 2014/08/25 06:24:35 Rather than having to create the three local varia
davidben 2014/08/26 22:13:51 Done.
913 916
914 // If not done, stay in this state 917 // If not done, stay in this state
915 if (net_error == ERR_IO_PENDING) { 918 if (net_error == ERR_IO_PENDING) {
916 GotoState(STATE_HANDSHAKE); 919 GotoState(STATE_HANDSHAKE);
917 } else { 920 } else {
918 LOG(ERROR) << "handshake failed; returned " << rv 921 LOG(ERROR) << "handshake failed; returned " << rv
919 << ", SSL error code " << ssl_error 922 << ", SSL error code " << ssl_error
920 << ", net_error " << net_error; 923 << ", net_error " << net_error;
921 net_log_.AddEvent( 924 net_log_.AddEvent(
922 NetLog::TYPE_SSL_HANDSHAKE_ERROR, 925 NetLog::TYPE_SSL_HANDSHAKE_ERROR,
923 CreateNetLogSSLErrorCallback(net_error, ssl_error)); 926 CreateNetLogOpenSSLErrorCallback(
927 net_error, ssl_error, error_code, file, line));
924 } 928 }
925 } 929 }
926 return net_error; 930 return net_error;
927 } 931 }
928 932
929 int SSLClientSocketOpenSSL::DoChannelIDLookup() { 933 int SSLClientSocketOpenSSL::DoChannelIDLookup() {
930 GotoState(STATE_CHANNEL_ID_LOOKUP_COMPLETE); 934 GotoState(STATE_CHANNEL_ID_LOOKUP_COMPLETE);
931 return channel_id_service_->GetOrCreateChannelID( 935 return channel_id_service_->GetOrCreateChannelID(
932 host_and_port_.host(), 936 host_and_port_.host(),
933 &channel_id_private_key_, 937 &channel_id_private_key_,
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 if (handshake_succeeded_ && marked_session_as_good_) 1623 if (handshake_succeeded_ && marked_session_as_good_)
1620 OnHandshakeCompletion(); 1624 OnHandshakeCompletion();
1621 } 1625 }
1622 1626
1623 scoped_refptr<X509Certificate> 1627 scoped_refptr<X509Certificate>
1624 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { 1628 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const {
1625 return server_cert_; 1629 return server_cert_;
1626 } 1630 }
1627 1631
1628 } // namespace net 1632 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698