Chromium Code Reviews| 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 // 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 <openssl/err.h> | 10 #include <openssl/err.h> |
| 11 #include <openssl/opensslv.h> | 11 #include <openssl/opensslv.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 "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
| 22 #include "net/cert/cert_verifier.h" | 22 #include "net/cert/cert_verifier.h" |
| 23 #include "net/cert/single_request_cert_verifier.h" | 23 #include "net/cert/single_request_cert_verifier.h" |
| 24 #include "net/cert/x509_certificate_net_log_param.h" | 24 #include "net/cert/x509_certificate_net_log_param.h" |
| 25 #include "net/socket/openssl_ssl_util.h" | 25 #include "net/socket/openssl_ssl_util.h" |
| 26 #include "net/socket/ssl_client_socket_pool.h" | |
|
wtc
2014/07/15 19:27:59
We should be able to remove this now.
mshelley
2014/07/17 00:28:45
Done.
| |
| 26 #include "net/socket/ssl_error_params.h" | 27 #include "net/socket/ssl_error_params.h" |
| 27 #include "net/socket/ssl_session_cache_openssl.h" | 28 #include "net/socket/ssl_session_cache_openssl.h" |
| 28 #include "net/ssl/openssl_client_key_store.h" | 29 #include "net/ssl/openssl_client_key_store.h" |
| 29 #include "net/ssl/ssl_cert_request_info.h" | 30 #include "net/ssl/ssl_cert_request_info.h" |
| 30 #include "net/ssl/ssl_connection_status_flags.h" | 31 #include "net/ssl/ssl_connection_status_flags.h" |
| 31 #include "net/ssl/ssl_info.h" | 32 #include "net/ssl/ssl_info.h" |
| 32 | 33 |
| 33 namespace net { | 34 namespace net { |
| 34 | 35 |
| 35 namespace { | 36 namespace { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 return SSL_CONNECTION_VERSION_TLS1; | 81 return SSL_CONNECTION_VERSION_TLS1; |
| 81 case 0x0302: | 82 case 0x0302: |
| 82 return SSL_CONNECTION_VERSION_TLS1_1; | 83 return SSL_CONNECTION_VERSION_TLS1_1; |
| 83 case 0x0303: | 84 case 0x0303: |
| 84 return SSL_CONNECTION_VERSION_TLS1_2; | 85 return SSL_CONNECTION_VERSION_TLS1_2; |
| 85 default: | 86 default: |
| 86 return SSL_CONNECTION_VERSION_UNKNOWN; | 87 return SSL_CONNECTION_VERSION_UNKNOWN; |
| 87 } | 88 } |
| 88 } | 89 } |
| 89 | 90 |
| 90 // Compute a unique key string for the SSL session cache. |socket| is an | |
| 91 // input socket object. Return a string. | |
| 92 std::string GetSocketSessionCacheKey(const SSLClientSocketOpenSSL& socket) { | |
| 93 std::string result = socket.host_and_port().ToString(); | |
| 94 result.append("/"); | |
| 95 result.append(socket.ssl_session_cache_shard()); | |
| 96 return result; | |
| 97 } | |
| 98 | 91 |
| 99 } // namespace | 92 } // namespace |
| 100 | 93 |
| 101 class SSLClientSocketOpenSSL::SSLContext { | 94 class SSLClientSocketOpenSSL::SSLContext { |
| 102 public: | 95 public: |
| 103 static SSLContext* GetInstance() { return Singleton<SSLContext>::get(); } | 96 static SSLContext* GetInstance() { return Singleton<SSLContext>::get(); } |
| 104 SSL_CTX* ssl_ctx() { return ssl_ctx_.get(); } | 97 SSL_CTX* ssl_ctx() { return ssl_ctx_.get(); } |
| 105 SSLSessionCacheOpenSSL* session_cache() { return &session_cache_; } | 98 SSLSessionCacheOpenSSL* session_cache() { return &session_cache_; } |
| 106 | 99 |
| 107 SSLClientSocketOpenSSL* GetClientSocketFromSSL(const SSL* ssl) { | 100 SSLClientSocketOpenSSL* GetClientSocketFromSSL(const SSL* ssl) { |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 132 // TODO(kristianm): Only select this if ssl_config_.next_proto is not empty. | 125 // TODO(kristianm): Only select this if ssl_config_.next_proto is not empty. |
| 133 // It would be better if the callback were not a global setting, | 126 // It would be better if the callback were not a global setting, |
| 134 // but that is an OpenSSL issue. | 127 // but that is an OpenSSL issue. |
| 135 SSL_CTX_set_next_proto_select_cb(ssl_ctx_.get(), SelectNextProtoCallback, | 128 SSL_CTX_set_next_proto_select_cb(ssl_ctx_.get(), SelectNextProtoCallback, |
| 136 NULL); | 129 NULL); |
| 137 } | 130 } |
| 138 | 131 |
| 139 static std::string GetSessionCacheKey(const SSL* ssl) { | 132 static std::string GetSessionCacheKey(const SSL* ssl) { |
| 140 SSLClientSocketOpenSSL* socket = GetInstance()->GetClientSocketFromSSL(ssl); | 133 SSLClientSocketOpenSSL* socket = GetInstance()->GetClientSocketFromSSL(ssl); |
| 141 DCHECK(socket); | 134 DCHECK(socket); |
| 142 return GetSocketSessionCacheKey(*socket); | 135 return socket->GetSessionCacheKey(); |
| 143 } | 136 } |
| 144 | 137 |
| 145 static SSLSessionCacheOpenSSL::Config kDefaultSessionCacheConfig; | 138 static SSLSessionCacheOpenSSL::Config kDefaultSessionCacheConfig; |
| 146 | 139 |
| 147 static int ClientCertCallback(SSL* ssl, X509** x509, EVP_PKEY** pkey) { | 140 static int ClientCertCallback(SSL* ssl, X509** x509, EVP_PKEY** pkey) { |
| 148 SSLClientSocketOpenSSL* socket = GetInstance()->GetClientSocketFromSSL(ssl); | 141 SSLClientSocketOpenSSL* socket = GetInstance()->GetClientSocketFromSSL(ssl); |
| 149 CHECK(socket); | 142 CHECK(socket); |
| 150 return socket->ClientCertRequestCallback(ssl, x509, pkey); | 143 return socket->ClientCertRequestCallback(ssl, x509, pkey); |
| 151 } | 144 } |
| 152 | 145 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 353 transport_bio_(NULL), | 346 transport_bio_(NULL), |
| 354 transport_(transport_socket.Pass()), | 347 transport_(transport_socket.Pass()), |
| 355 host_and_port_(host_and_port), | 348 host_and_port_(host_and_port), |
| 356 ssl_config_(ssl_config), | 349 ssl_config_(ssl_config), |
| 357 ssl_session_cache_shard_(context.ssl_session_cache_shard), | 350 ssl_session_cache_shard_(context.ssl_session_cache_shard), |
| 358 trying_cached_session_(false), | 351 trying_cached_session_(false), |
| 359 next_handshake_state_(STATE_NONE), | 352 next_handshake_state_(STATE_NONE), |
| 360 npn_status_(kNextProtoUnsupported), | 353 npn_status_(kNextProtoUnsupported), |
| 361 channel_id_request_return_value_(ERR_UNEXPECTED), | 354 channel_id_request_return_value_(ERR_UNEXPECTED), |
| 362 channel_id_xtn_negotiated_(false), | 355 channel_id_xtn_negotiated_(false), |
| 363 net_log_(transport_->socket()->NetLog()) {} | 356 net_log_(transport_->socket()->NetLog()) { |
| 357 } | |
| 364 | 358 |
| 365 SSLClientSocketOpenSSL::~SSLClientSocketOpenSSL() { | 359 SSLClientSocketOpenSSL::~SSLClientSocketOpenSSL() { |
| 366 Disconnect(); | 360 Disconnect(); |
| 367 } | 361 } |
| 368 | 362 |
| 363 std::string SSLClientSocketOpenSSL::GetSessionCacheKey() const { | |
| 364 return FormatSessionCacheKey(host_and_port_.ToString(), | |
| 365 ssl_session_cache_shard_); | |
| 366 } | |
| 367 | |
| 368 bool SSLClientSocketOpenSSL::InSessionCache() const { | |
| 369 SSLContext* context = SSLContext::GetInstance(); | |
| 370 std::string cache_key = GetSessionCacheKey(); | |
| 371 return context->session_cache()->SSLSessionIsInCache(cache_key); | |
| 372 } | |
| 373 | |
| 374 void SSLClientSocketOpenSSL::SetHandshakeSuccessCallback( | |
| 375 const base::Closure& callback) { | |
| 376 success_callback_ = callback; | |
| 377 SSLContext* context = SSLContext::GetInstance(); | |
| 378 context->session_cache()->SetSessionAddedCallback( | |
| 379 ssl_, | |
| 380 base::Bind(&SSLClientSocketOpenSSL::OnHandshakeSuccess, | |
| 381 base::Unretained(this))); | |
| 382 } | |
| 383 | |
| 384 void SSLClientSocketOpenSSL::SetHandshakeFailureCallback( | |
| 385 const base::Closure& callback) { | |
| 386 error_callback_ = callback; | |
| 387 } | |
| 388 | |
| 389 void SSLClientSocketOpenSSL::OnHandshakeSuccess() { | |
| 390 error_callback_.Reset(); | |
| 391 base::ResetAndReturn(&success_callback_).Run(); | |
| 392 } | |
| 393 | |
| 394 void SSLClientSocketOpenSSL::OnHandshakeFailure() { | |
| 395 if (!error_callback_.is_null()) | |
| 396 base::ResetAndReturn(&error_callback_).Run(); | |
| 397 } | |
| 398 | |
| 369 void SSLClientSocketOpenSSL::GetSSLCertRequestInfo( | 399 void SSLClientSocketOpenSSL::GetSSLCertRequestInfo( |
| 370 SSLCertRequestInfo* cert_request_info) { | 400 SSLCertRequestInfo* cert_request_info) { |
| 371 cert_request_info->host_and_port = host_and_port_; | 401 cert_request_info->host_and_port = host_and_port_; |
| 372 cert_request_info->cert_authorities = cert_authorities_; | 402 cert_request_info->cert_authorities = cert_authorities_; |
| 373 cert_request_info->cert_key_types = cert_key_types_; | 403 cert_request_info->cert_key_types = cert_key_types_; |
| 374 } | 404 } |
| 375 | 405 |
| 376 SSLClientSocket::NextProtoStatus SSLClientSocketOpenSSL::GetNextProto( | 406 SSLClientSocket::NextProtoStatus SSLClientSocketOpenSSL::GetNextProto( |
| 377 std::string* proto, std::string* server_protos) { | 407 std::string* proto, std::string* server_protos) { |
| 378 *proto = npn_proto_; | 408 *proto = npn_proto_; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 422 } | 452 } |
| 423 | 453 |
| 424 // Set SSL to client mode. Handshake happens in the loop below. | 454 // Set SSL to client mode. Handshake happens in the loop below. |
| 425 SSL_set_connect_state(ssl_); | 455 SSL_set_connect_state(ssl_); |
| 426 | 456 |
| 427 GotoState(STATE_HANDSHAKE); | 457 GotoState(STATE_HANDSHAKE); |
| 428 rv = DoHandshakeLoop(OK); | 458 rv = DoHandshakeLoop(OK); |
| 429 if (rv == ERR_IO_PENDING) { | 459 if (rv == ERR_IO_PENDING) { |
| 430 user_connect_callback_ = callback; | 460 user_connect_callback_ = callback; |
| 431 } else { | 461 } else { |
| 432 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); | 462 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); |
|
wtc
2014/07/15 19:27:59
Add
if (rv < OK)
OnHandshakeFailure();
mshelley
2014/07/17 00:28:45
Done.
| |
| 433 } | 463 } |
| 434 | 464 |
| 435 return rv > OK ? OK : rv; | 465 return rv > OK ? OK : rv; |
| 436 } | 466 } |
| 437 | 467 |
| 438 void SSLClientSocketOpenSSL::Disconnect() { | 468 void SSLClientSocketOpenSSL::Disconnect() { |
| 469 OnHandshakeFailure(); | |
| 470 SSLContext* context = SSLContext::GetInstance(); | |
| 471 context->session_cache()->RemoveSessionAddedCallback(ssl_); | |
|
wtc
2014/07/15 19:27:58
Move these two lines into the if (ssl_) statement
mshelley
2014/07/17 00:28:45
Done.
| |
| 439 if (ssl_) { | 472 if (ssl_) { |
| 440 // Calling SSL_shutdown prevents the session from being marked as | 473 // Calling SSL_shutdown prevents the session from being marked as |
| 441 // unresumable. | 474 // unresumable. |
| 442 SSL_shutdown(ssl_); | 475 SSL_shutdown(ssl_); |
| 443 SSL_free(ssl_); | 476 SSL_free(ssl_); |
| 444 ssl_ = NULL; | 477 ssl_ = NULL; |
| 445 } | 478 } |
| 446 if (transport_bio_) { | 479 if (transport_bio_) { |
| 447 BIO_free_all(transport_bio_); | 480 BIO_free_all(transport_bio_); |
| 448 transport_bio_ = NULL; | 481 transport_bio_ = NULL; |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 651 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); | 684 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); |
| 652 | 685 |
| 653 ssl_ = SSL_new(context->ssl_ctx()); | 686 ssl_ = SSL_new(context->ssl_ctx()); |
| 654 if (!ssl_ || !context->SetClientSocketForSSL(ssl_, this)) | 687 if (!ssl_ || !context->SetClientSocketForSSL(ssl_, this)) |
| 655 return ERR_UNEXPECTED; | 688 return ERR_UNEXPECTED; |
| 656 | 689 |
| 657 if (!SSL_set_tlsext_host_name(ssl_, host_and_port_.host().c_str())) | 690 if (!SSL_set_tlsext_host_name(ssl_, host_and_port_.host().c_str())) |
| 658 return ERR_UNEXPECTED; | 691 return ERR_UNEXPECTED; |
| 659 | 692 |
| 660 trying_cached_session_ = context->session_cache()->SetSSLSessionWithKey( | 693 trying_cached_session_ = context->session_cache()->SetSSLSessionWithKey( |
| 661 ssl_, GetSocketSessionCacheKey(*this)); | 694 ssl_, GetSessionCacheKey()); |
| 662 | 695 |
| 663 BIO* ssl_bio = NULL; | 696 BIO* ssl_bio = NULL; |
| 664 // 0 => use default buffer sizes. | 697 // 0 => use default buffer sizes. |
| 665 if (!BIO_new_bio_pair(&ssl_bio, 0, &transport_bio_, 0)) | 698 if (!BIO_new_bio_pair(&ssl_bio, 0, &transport_bio_, 0)) |
| 666 return ERR_UNEXPECTED; | 699 return ERR_UNEXPECTED; |
| 667 DCHECK(ssl_bio); | 700 DCHECK(ssl_bio); |
| 668 DCHECK(transport_bio_); | 701 DCHECK(transport_bio_); |
| 669 | 702 |
| 670 SSL_set_bio(ssl_, ssl_bio, ssl_bio); | 703 SSL_set_bio(ssl_, ssl_bio, ssl_bio); |
| 671 | 704 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 788 if (!transport_recv_eof_ && BufferRecv() != ERR_IO_PENDING) | 821 if (!transport_recv_eof_ && BufferRecv() != ERR_IO_PENDING) |
| 789 network_moved = true; | 822 network_moved = true; |
| 790 return network_moved; | 823 return network_moved; |
| 791 } | 824 } |
| 792 | 825 |
| 793 int SSLClientSocketOpenSSL::DoHandshake() { | 826 int SSLClientSocketOpenSSL::DoHandshake() { |
| 794 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); | 827 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); |
| 795 int net_error = OK; | 828 int net_error = OK; |
| 796 int rv = SSL_do_handshake(ssl_); | 829 int rv = SSL_do_handshake(ssl_); |
| 797 | 830 |
| 831 if (rv <= 0) | |
| 832 OnHandshakeFailure(); | |
|
wtc
2014/07/15 19:27:59
Delete this. I think it's better to do this after
mshelley
2014/07/17 00:28:45
Done.
| |
| 833 | |
| 798 if (client_auth_cert_needed_) { | 834 if (client_auth_cert_needed_) { |
| 799 net_error = ERR_SSL_CLIENT_AUTH_CERT_NEEDED; | 835 net_error = ERR_SSL_CLIENT_AUTH_CERT_NEEDED; |
| 800 // If the handshake already succeeded (because the server requests but | 836 // If the handshake already succeeded (because the server requests but |
| 801 // doesn't require a client cert), we need to invalidate the SSL session | 837 // doesn't require a client cert), we need to invalidate the SSL session |
| 802 // so that we won't try to resume the non-client-authenticated session in | 838 // so that we won't try to resume the non-client-authenticated session in |
| 803 // the next handshake. This will cause the server to ask for a client | 839 // the next handshake. This will cause the server to ask for a client |
| 804 // cert again. | 840 // cert again. |
| 805 if (rv == 1) { | 841 if (rv == 1) { |
| 806 // Remove from session cache but don't clear this connection. | 842 // Remove from session cache but don't clear this connection. |
| 807 SSL_SESSION* session = SSL_get_session(ssl_); | 843 SSL_SESSION* session = SSL_get_session(ssl_); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 916 if (!server_cert_chain_->IsValid()) | 952 if (!server_cert_chain_->IsValid()) |
| 917 DVLOG(1) << "UpdateServerCert received invalid certificate chain from peer"; | 953 DVLOG(1) << "UpdateServerCert received invalid certificate chain from peer"; |
| 918 | 954 |
| 919 return server_cert_.get(); | 955 return server_cert_.get(); |
| 920 } | 956 } |
| 921 | 957 |
| 922 void SSLClientSocketOpenSSL::OnHandshakeIOComplete(int result) { | 958 void SSLClientSocketOpenSSL::OnHandshakeIOComplete(int result) { |
| 923 int rv = DoHandshakeLoop(result); | 959 int rv = DoHandshakeLoop(result); |
| 924 if (rv != ERR_IO_PENDING) { | 960 if (rv != ERR_IO_PENDING) { |
| 925 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); | 961 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); |
| 926 DoConnectCallback(rv); | 962 DoConnectCallback(rv); |
|
wtc
2014/07/15 19:27:59
I think we should do
if (rv < OK)
OnHandshak
mshelley
2014/07/17 00:28:44
Done.
| |
| 927 } | 963 } |
| 928 } | 964 } |
| 929 | 965 |
| 930 void SSLClientSocketOpenSSL::OnSendComplete(int result) { | 966 void SSLClientSocketOpenSSL::OnSendComplete(int result) { |
| 931 if (next_handshake_state_ == STATE_HANDSHAKE) { | 967 if (next_handshake_state_ == STATE_HANDSHAKE) { |
| 932 // In handshake phase. | 968 // In handshake phase. |
| 933 OnHandshakeIOComplete(result); | 969 OnHandshakeIOComplete(result); |
| 934 return; | 970 return; |
| 935 } | 971 } |
| 936 | 972 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1057 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_RECEIVED, | 1093 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_RECEIVED, |
| 1058 rv, user_read_buf_->data()); | 1094 rv, user_read_buf_->data()); |
| 1059 } | 1095 } |
| 1060 return rv; | 1096 return rv; |
| 1061 } | 1097 } |
| 1062 | 1098 |
| 1063 int total_bytes_read = 0; | 1099 int total_bytes_read = 0; |
| 1064 do { | 1100 do { |
| 1065 rv = SSL_read(ssl_, user_read_buf_->data() + total_bytes_read, | 1101 rv = SSL_read(ssl_, user_read_buf_->data() + total_bytes_read, |
| 1066 user_read_buf_len_ - total_bytes_read); | 1102 user_read_buf_len_ - total_bytes_read); |
| 1103 // Failure of the first read attempt indicates a failed false start | |
| 1104 // connection. | |
|
wtc
2014/07/15 19:27:59
Update this comment.
mshelley
2014/07/17 00:28:45
Done.
| |
| 1105 if (rv <= OK) | |
|
wtc
2014/07/15 19:27:59
This should be
if (rv <= 0)
You can combine t
mshelley
2014/07/17 00:28:45
Done.
| |
| 1106 OnHandshakeFailure(); | |
| 1067 if (rv > 0) | 1107 if (rv > 0) |
| 1068 total_bytes_read += rv; | 1108 total_bytes_read += rv; |
| 1069 } while (total_bytes_read < user_read_buf_len_ && rv > 0); | 1109 } while (total_bytes_read < user_read_buf_len_ && rv > 0); |
| 1070 | 1110 |
| 1071 if (total_bytes_read == user_read_buf_len_) { | 1111 if (total_bytes_read == user_read_buf_len_) { |
| 1072 rv = total_bytes_read; | 1112 rv = total_bytes_read; |
| 1073 } else { | 1113 } else { |
| 1074 // Otherwise, an error occurred (rv <= 0). The error needs to be handled | 1114 // Otherwise, an error occurred (rv <= 0). The error needs to be handled |
| 1075 // immediately, while the OpenSSL errors are still available in | 1115 // immediately, while the OpenSSL errors are still available in |
| 1076 // thread-local storage. However, the handled/remapped error code should | 1116 // thread-local storage. However, the handled/remapped error code should |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1109 if (rv >= 0) { | 1149 if (rv >= 0) { |
| 1110 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_RECEIVED, rv, | 1150 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_RECEIVED, rv, |
| 1111 user_read_buf_->data()); | 1151 user_read_buf_->data()); |
| 1112 } | 1152 } |
| 1113 return rv; | 1153 return rv; |
| 1114 } | 1154 } |
| 1115 | 1155 |
| 1116 int SSLClientSocketOpenSSL::DoPayloadWrite() { | 1156 int SSLClientSocketOpenSSL::DoPayloadWrite() { |
| 1117 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); | 1157 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); |
| 1118 int rv = SSL_write(ssl_, user_write_buf_->data(), user_write_buf_len_); | 1158 int rv = SSL_write(ssl_, user_write_buf_->data(), user_write_buf_len_); |
| 1119 | 1159 // Failure of the second write attempt indicates a failed false start |
| 1160 // connection. | |
| 1161 if (rv <= 0) { | |
|
wtc
2014/07/15 19:27:59
This should be
if (rv < 0)
You can just call On
mshelley
2014/07/17 00:28:45
Done.
| |
| 1162 OnHandshakeFailure(); | |
| 1163 } | |
|
wtc
2014/07/15 19:27:59
Omit the curly braces.
mshelley
2014/07/17 00:28:45
Done.
| |
| 1120 if (rv >= 0) { | 1164 if (rv >= 0) { |
| 1121 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_SENT, rv, | 1165 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_SENT, rv, |
| 1122 user_write_buf_->data()); | 1166 user_write_buf_->data()); |
| 1123 return rv; | 1167 return rv; |
| 1124 } | 1168 } |
| 1125 | 1169 |
| 1126 int err = SSL_get_error(ssl_, rv); | 1170 int err = SSL_get_error(ssl_, rv); |
| 1127 return MapOpenSSLError(err, err_tracer); | 1171 return MapOpenSSLError(err, err_tracer); |
| 1128 } | 1172 } |
| 1129 | 1173 |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1430 DVLOG(2) << "next protocol: '" << npn_proto_ << "' status: " << npn_status_; | 1474 DVLOG(2) << "next protocol: '" << npn_proto_ << "' status: " << npn_status_; |
| 1431 return SSL_TLSEXT_ERR_OK; | 1475 return SSL_TLSEXT_ERR_OK; |
| 1432 } | 1476 } |
| 1433 | 1477 |
| 1434 scoped_refptr<X509Certificate> | 1478 scoped_refptr<X509Certificate> |
| 1435 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { | 1479 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { |
| 1436 return server_cert_; | 1480 return server_cert_; |
| 1437 } | 1481 } |
| 1438 | 1482 |
| 1439 } // namespace net | 1483 } // namespace net |
| OLD | NEW |