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> |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 return SSL_CONNECTION_VERSION_TLS1; | 80 return SSL_CONNECTION_VERSION_TLS1; |
| 81 case 0x0302: | 81 case 0x0302: |
| 82 return SSL_CONNECTION_VERSION_TLS1_1; | 82 return SSL_CONNECTION_VERSION_TLS1_1; |
| 83 case 0x0303: | 83 case 0x0303: |
| 84 return SSL_CONNECTION_VERSION_TLS1_2; | 84 return SSL_CONNECTION_VERSION_TLS1_2; |
| 85 default: | 85 default: |
| 86 return SSL_CONNECTION_VERSION_UNKNOWN; | 86 return SSL_CONNECTION_VERSION_UNKNOWN; |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 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 | |
| 99 } // namespace | 90 } // namespace |
| 100 | 91 |
| 101 class SSLClientSocketOpenSSL::SSLContext { | 92 class SSLClientSocketOpenSSL::SSLContext { |
| 102 public: | 93 public: |
| 103 static SSLContext* GetInstance() { return Singleton<SSLContext>::get(); } | 94 static SSLContext* GetInstance() { return Singleton<SSLContext>::get(); } |
| 104 SSL_CTX* ssl_ctx() { return ssl_ctx_.get(); } | 95 SSL_CTX* ssl_ctx() { return ssl_ctx_.get(); } |
| 105 SSLSessionCacheOpenSSL* session_cache() { return &session_cache_; } | 96 SSLSessionCacheOpenSSL* session_cache() { return &session_cache_; } |
| 106 | 97 |
| 107 SSLClientSocketOpenSSL* GetClientSocketFromSSL(const SSL* ssl) { | 98 SSLClientSocketOpenSSL* GetClientSocketFromSSL(const SSL* ssl) { |
| 108 DCHECK(ssl); | 99 DCHECK(ssl); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 132 // TODO(kristianm): Only select this if ssl_config_.next_proto is not empty. | 123 // 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, | 124 // It would be better if the callback were not a global setting, |
| 134 // but that is an OpenSSL issue. | 125 // but that is an OpenSSL issue. |
| 135 SSL_CTX_set_next_proto_select_cb(ssl_ctx_.get(), SelectNextProtoCallback, | 126 SSL_CTX_set_next_proto_select_cb(ssl_ctx_.get(), SelectNextProtoCallback, |
| 136 NULL); | 127 NULL); |
| 137 } | 128 } |
| 138 | 129 |
| 139 static std::string GetSessionCacheKey(const SSL* ssl) { | 130 static std::string GetSessionCacheKey(const SSL* ssl) { |
| 140 SSLClientSocketOpenSSL* socket = GetInstance()->GetClientSocketFromSSL(ssl); | 131 SSLClientSocketOpenSSL* socket = GetInstance()->GetClientSocketFromSSL(ssl); |
| 141 DCHECK(socket); | 132 DCHECK(socket); |
| 142 return GetSocketSessionCacheKey(*socket); | 133 return socket->GetSessionCacheKey(); |
| 143 } | 134 } |
| 144 | 135 |
| 145 static SSLSessionCacheOpenSSL::Config kDefaultSessionCacheConfig; | 136 static SSLSessionCacheOpenSSL::Config kDefaultSessionCacheConfig; |
| 146 | 137 |
| 147 static int ClientCertCallback(SSL* ssl, X509** x509, EVP_PKEY** pkey) { | 138 static int ClientCertCallback(SSL* ssl, X509** x509, EVP_PKEY** pkey) { |
| 148 SSLClientSocketOpenSSL* socket = GetInstance()->GetClientSocketFromSSL(ssl); | 139 SSLClientSocketOpenSSL* socket = GetInstance()->GetClientSocketFromSSL(ssl); |
| 149 CHECK(socket); | 140 CHECK(socket); |
| 150 return socket->ClientCertRequestCallback(ssl, x509, pkey); | 141 return socket->ClientCertRequestCallback(ssl, x509, pkey); |
| 151 } | 142 } |
| 152 | 143 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 353 transport_bio_(NULL), | 344 transport_bio_(NULL), |
| 354 transport_(transport_socket.Pass()), | 345 transport_(transport_socket.Pass()), |
| 355 host_and_port_(host_and_port), | 346 host_and_port_(host_and_port), |
| 356 ssl_config_(ssl_config), | 347 ssl_config_(ssl_config), |
| 357 ssl_session_cache_shard_(context.ssl_session_cache_shard), | 348 ssl_session_cache_shard_(context.ssl_session_cache_shard), |
| 358 trying_cached_session_(false), | 349 trying_cached_session_(false), |
| 359 next_handshake_state_(STATE_NONE), | 350 next_handshake_state_(STATE_NONE), |
| 360 npn_status_(kNextProtoUnsupported), | 351 npn_status_(kNextProtoUnsupported), |
| 361 channel_id_request_return_value_(ERR_UNEXPECTED), | 352 channel_id_request_return_value_(ERR_UNEXPECTED), |
| 362 channel_id_xtn_negotiated_(false), | 353 channel_id_xtn_negotiated_(false), |
| 363 net_log_(transport_->socket()->NetLog()) {} | 354 net_log_(transport_->socket()->NetLog()) { |
| 355 } | |
| 364 | 356 |
| 365 SSLClientSocketOpenSSL::~SSLClientSocketOpenSSL() { | 357 SSLClientSocketOpenSSL::~SSLClientSocketOpenSSL() { |
| 366 Disconnect(); | 358 Disconnect(); |
| 367 } | 359 } |
| 368 | 360 |
| 361 bool SSLClientSocketOpenSSL::InSessionCache() const { | |
| 362 SSLContext* context = SSLContext::GetInstance(); | |
| 363 std::string cache_key = GetSessionCacheKey(); | |
| 364 return context->session_cache()->SSLSessionIsInCache(cache_key); | |
| 365 } | |
| 366 | |
| 367 void SSLClientSocketOpenSSL::SetHandshakeSuccessCallback( | |
| 368 const base::Closure& callback) { | |
| 369 success_callback_ = callback; | |
|
mmenke
2014/07/22 16:24:11
optional: I think using one handshake complete ca
wtc
2014/07/23 02:03:26
I believe all three reviewers suggested this. Mack
mshelley
2014/07/23 03:49:56
Ryan and Wan-Teh have suggested this as well. My p
mshelley
2014/07/23 03:49:56
Since we decided to treat failures and successes i
| |
| 370 SSLContext* context = SSLContext::GetInstance(); | |
| 371 context->session_cache()->SetSessionAddedCallback( | |
| 372 ssl_, | |
| 373 base::Bind(&SSLClientSocketOpenSSL::OnHandshakeSuccess, | |
| 374 base::Unretained(this))); | |
| 375 } | |
| 376 | |
| 377 void SSLClientSocketOpenSSL::SetHandshakeFailureCallback( | |
| 378 const base::Closure& callback) { | |
| 379 error_callback_ = callback; | |
| 380 } | |
| 381 | |
| 369 void SSLClientSocketOpenSSL::GetSSLCertRequestInfo( | 382 void SSLClientSocketOpenSSL::GetSSLCertRequestInfo( |
| 370 SSLCertRequestInfo* cert_request_info) { | 383 SSLCertRequestInfo* cert_request_info) { |
| 371 cert_request_info->host_and_port = host_and_port_; | 384 cert_request_info->host_and_port = host_and_port_; |
| 372 cert_request_info->cert_authorities = cert_authorities_; | 385 cert_request_info->cert_authorities = cert_authorities_; |
| 373 cert_request_info->cert_key_types = cert_key_types_; | 386 cert_request_info->cert_key_types = cert_key_types_; |
| 374 } | 387 } |
| 375 | 388 |
| 376 SSLClientSocket::NextProtoStatus SSLClientSocketOpenSSL::GetNextProto( | 389 SSLClientSocket::NextProtoStatus SSLClientSocketOpenSSL::GetNextProto( |
| 377 std::string* proto, std::string* server_protos) { | 390 std::string* proto, std::string* server_protos) { |
| 378 *proto = npn_proto_; | 391 *proto = npn_proto_; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 425 SSL_set_connect_state(ssl_); | 438 SSL_set_connect_state(ssl_); |
| 426 | 439 |
| 427 GotoState(STATE_HANDSHAKE); | 440 GotoState(STATE_HANDSHAKE); |
| 428 rv = DoHandshakeLoop(OK); | 441 rv = DoHandshakeLoop(OK); |
| 429 if (rv == ERR_IO_PENDING) { | 442 if (rv == ERR_IO_PENDING) { |
| 430 user_connect_callback_ = callback; | 443 user_connect_callback_ = callback; |
| 431 } else { | 444 } else { |
| 432 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); | 445 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); |
| 433 } | 446 } |
| 434 | 447 |
| 448 if (rv < OK && rv != ERR_IO_PENDING) | |
| 449 OnHandshakeFailure(); | |
| 450 | |
| 435 return rv > OK ? OK : rv; | 451 return rv > OK ? OK : rv; |
| 436 } | 452 } |
| 437 | 453 |
| 438 void SSLClientSocketOpenSSL::Disconnect() { | 454 void SSLClientSocketOpenSSL::Disconnect() { |
| 455 OnHandshakeFailure(); | |
| 439 if (ssl_) { | 456 if (ssl_) { |
| 457 SSLContext* context = SSLContext::GetInstance(); | |
| 458 context->session_cache()->RemoveSessionAddedCallback(ssl_); | |
| 440 // Calling SSL_shutdown prevents the session from being marked as | 459 // Calling SSL_shutdown prevents the session from being marked as |
| 441 // unresumable. | 460 // unresumable. |
| 442 SSL_shutdown(ssl_); | 461 SSL_shutdown(ssl_); |
| 443 SSL_free(ssl_); | 462 SSL_free(ssl_); |
| 444 ssl_ = NULL; | 463 ssl_ = NULL; |
| 445 } | 464 } |
| 446 if (transport_bio_) { | 465 if (transport_bio_) { |
| 447 BIO_free_all(transport_bio_); | 466 BIO_free_all(transport_bio_); |
| 448 transport_bio_ = NULL; | 467 transport_bio_ = NULL; |
| 449 } | 468 } |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 605 | 624 |
| 606 if (rv == ERR_IO_PENDING) { | 625 if (rv == ERR_IO_PENDING) { |
| 607 user_read_callback_ = callback; | 626 user_read_callback_ = callback; |
| 608 } else { | 627 } else { |
| 609 if (rv > 0) | 628 if (rv > 0) |
| 610 was_ever_used_ = true; | 629 was_ever_used_ = true; |
| 611 user_read_buf_ = NULL; | 630 user_read_buf_ = NULL; |
| 612 user_read_buf_len_ = 0; | 631 user_read_buf_len_ = 0; |
| 613 } | 632 } |
| 614 | 633 |
| 634 if (rv < 0 && rv != ERR_IO_PENDING) { | |
| 635 // Failure of a write attempt may indicate a failed false start | |
| 636 // connection. | |
| 637 OnHandshakeFailure(); | |
| 638 } | |
| 639 | |
| 615 return rv; | 640 return rv; |
| 616 } | 641 } |
| 617 | 642 |
| 618 int SSLClientSocketOpenSSL::Write(IOBuffer* buf, | 643 int SSLClientSocketOpenSSL::Write(IOBuffer* buf, |
| 619 int buf_len, | 644 int buf_len, |
| 620 const CompletionCallback& callback) { | 645 const CompletionCallback& callback) { |
| 621 user_write_buf_ = buf; | 646 user_write_buf_ = buf; |
| 622 user_write_buf_len_ = buf_len; | 647 user_write_buf_len_ = buf_len; |
| 623 | 648 |
| 624 int rv = DoWriteLoop(OK); | 649 int rv = DoWriteLoop(OK); |
| 625 | 650 |
| 626 if (rv == ERR_IO_PENDING) { | 651 if (rv == ERR_IO_PENDING) { |
| 627 user_write_callback_ = callback; | 652 user_write_callback_ = callback; |
| 628 } else { | 653 } else { |
| 629 if (rv > 0) | 654 if (rv > 0) |
| 630 was_ever_used_ = true; | 655 was_ever_used_ = true; |
| 631 user_write_buf_ = NULL; | 656 user_write_buf_ = NULL; |
| 632 user_write_buf_len_ = 0; | 657 user_write_buf_len_ = 0; |
| 633 } | 658 } |
| 634 | 659 |
| 660 if (rv < 0 && rv != ERR_IO_PENDING) { | |
| 661 // Failure of a write attempt may indicate a failed false start | |
| 662 // connection. | |
| 663 OnHandshakeFailure(); | |
| 664 } | |
| 665 | |
| 635 return rv; | 666 return rv; |
| 636 } | 667 } |
| 637 | 668 |
| 638 int SSLClientSocketOpenSSL::SetReceiveBufferSize(int32 size) { | 669 int SSLClientSocketOpenSSL::SetReceiveBufferSize(int32 size) { |
| 639 return transport_->socket()->SetReceiveBufferSize(size); | 670 return transport_->socket()->SetReceiveBufferSize(size); |
| 640 } | 671 } |
| 641 | 672 |
| 642 int SSLClientSocketOpenSSL::SetSendBufferSize(int32 size) { | 673 int SSLClientSocketOpenSSL::SetSendBufferSize(int32 size) { |
| 643 return transport_->socket()->SetSendBufferSize(size); | 674 return transport_->socket()->SetSendBufferSize(size); |
| 644 } | 675 } |
| 645 | 676 |
| 646 int SSLClientSocketOpenSSL::Init() { | 677 int SSLClientSocketOpenSSL::Init() { |
| 647 DCHECK(!ssl_); | 678 DCHECK(!ssl_); |
| 648 DCHECK(!transport_bio_); | 679 DCHECK(!transport_bio_); |
| 649 | 680 |
| 650 SSLContext* context = SSLContext::GetInstance(); | 681 SSLContext* context = SSLContext::GetInstance(); |
| 651 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); | 682 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); |
| 652 | 683 |
| 653 ssl_ = SSL_new(context->ssl_ctx()); | 684 ssl_ = SSL_new(context->ssl_ctx()); |
| 654 if (!ssl_ || !context->SetClientSocketForSSL(ssl_, this)) | 685 if (!ssl_ || !context->SetClientSocketForSSL(ssl_, this)) |
| 655 return ERR_UNEXPECTED; | 686 return ERR_UNEXPECTED; |
| 656 | 687 |
| 657 if (!SSL_set_tlsext_host_name(ssl_, host_and_port_.host().c_str())) | 688 if (!SSL_set_tlsext_host_name(ssl_, host_and_port_.host().c_str())) |
| 658 return ERR_UNEXPECTED; | 689 return ERR_UNEXPECTED; |
| 659 | 690 |
| 660 trying_cached_session_ = context->session_cache()->SetSSLSessionWithKey( | 691 trying_cached_session_ = context->session_cache()->SetSSLSessionWithKey( |
| 661 ssl_, GetSocketSessionCacheKey(*this)); | 692 ssl_, GetSessionCacheKey()); |
| 662 | 693 |
| 663 BIO* ssl_bio = NULL; | 694 BIO* ssl_bio = NULL; |
| 664 // 0 => use default buffer sizes. | 695 // 0 => use default buffer sizes. |
| 665 if (!BIO_new_bio_pair(&ssl_bio, 0, &transport_bio_, 0)) | 696 if (!BIO_new_bio_pair(&ssl_bio, 0, &transport_bio_, 0)) |
| 666 return ERR_UNEXPECTED; | 697 return ERR_UNEXPECTED; |
| 667 DCHECK(ssl_bio); | 698 DCHECK(ssl_bio); |
| 668 DCHECK(transport_bio_); | 699 DCHECK(transport_bio_); |
| 669 | 700 |
| 670 SSL_set_bio(ssl_, ssl_bio, ssl_bio); | 701 SSL_set_bio(ssl_, ssl_bio, ssl_bio); |
| 671 | 702 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 768 void SSLClientSocketOpenSSL::DoWriteCallback(int rv) { | 799 void SSLClientSocketOpenSSL::DoWriteCallback(int rv) { |
| 769 // Since Run may result in Write being called, clear |user_write_callback_| | 800 // Since Run may result in Write being called, clear |user_write_callback_| |
| 770 // up front. | 801 // up front. |
| 771 if (rv > 0) | 802 if (rv > 0) |
| 772 was_ever_used_ = true; | 803 was_ever_used_ = true; |
| 773 user_write_buf_ = NULL; | 804 user_write_buf_ = NULL; |
| 774 user_write_buf_len_ = 0; | 805 user_write_buf_len_ = 0; |
| 775 base::ResetAndReturn(&user_write_callback_).Run(rv); | 806 base::ResetAndReturn(&user_write_callback_).Run(rv); |
| 776 } | 807 } |
| 777 | 808 |
| 809 std::string SSLClientSocketOpenSSL::GetSessionCacheKey() const { | |
| 810 return CreateSessionCacheKey(host_and_port_, ssl_session_cache_shard_); | |
| 811 } | |
| 812 | |
| 813 void SSLClientSocketOpenSSL::OnHandshakeSuccess() { | |
| 814 error_callback_.Reset(); | |
| 815 base::ResetAndReturn(&success_callback_).Run(); | |
| 816 } | |
| 817 | |
| 818 void SSLClientSocketOpenSSL::OnHandshakeFailure() { | |
| 819 if (!error_callback_.is_null()) | |
| 820 success_callback_.Reset(); | |
| 821 base::ResetAndReturn(&error_callback_).Run(); | |
|
mmenke
2014/07/22 16:24:11
This should be:
if (!error_callback_.is_null()) {
mshelley
2014/07/23 03:49:56
Done.
| |
| 822 } | |
| 823 | |
| 778 bool SSLClientSocketOpenSSL::DoTransportIO() { | 824 bool SSLClientSocketOpenSSL::DoTransportIO() { |
| 779 bool network_moved = false; | 825 bool network_moved = false; |
| 780 int rv; | 826 int rv; |
| 781 // Read and write as much data as possible. The loop is necessary because | 827 // Read and write as much data as possible. The loop is necessary because |
| 782 // Write() may return synchronously. | 828 // Write() may return synchronously. |
| 783 do { | 829 do { |
| 784 rv = BufferSend(); | 830 rv = BufferSend(); |
| 785 if (rv != ERR_IO_PENDING && rv != 0) | 831 if (rv != ERR_IO_PENDING && rv != 0) |
| 786 network_moved = true; | 832 network_moved = true; |
| 787 } while (rv > 0); | 833 } while (rv > 0); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 917 DVLOG(1) << "UpdateServerCert received invalid certificate chain from peer"; | 963 DVLOG(1) << "UpdateServerCert received invalid certificate chain from peer"; |
| 918 | 964 |
| 919 return server_cert_.get(); | 965 return server_cert_.get(); |
| 920 } | 966 } |
| 921 | 967 |
| 922 void SSLClientSocketOpenSSL::OnHandshakeIOComplete(int result) { | 968 void SSLClientSocketOpenSSL::OnHandshakeIOComplete(int result) { |
| 923 int rv = DoHandshakeLoop(result); | 969 int rv = DoHandshakeLoop(result); |
| 924 if (rv != ERR_IO_PENDING) { | 970 if (rv != ERR_IO_PENDING) { |
| 925 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); | 971 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); |
| 926 DoConnectCallback(rv); | 972 DoConnectCallback(rv); |
| 973 if (rv < OK) | |
| 974 OnHandshakeFailure(); | |
|
mmenke
2014/07/22 16:24:11
This call isn't needed - we call OnHandshakeFailur
mshelley
2014/07/23 03:49:56
In response to Ryan's comment on line 1052 of http
| |
| 927 } | 975 } |
| 928 } | 976 } |
| 929 | 977 |
| 930 void SSLClientSocketOpenSSL::OnSendComplete(int result) { | 978 void SSLClientSocketOpenSSL::OnSendComplete(int result) { |
| 931 if (next_handshake_state_ == STATE_HANDSHAKE) { | 979 if (next_handshake_state_ == STATE_HANDSHAKE) { |
| 932 // In handshake phase. | 980 // In handshake phase. |
| 933 OnHandshakeIOComplete(result); | 981 OnHandshakeIOComplete(result); |
| 934 return; | 982 return; |
| 935 } | 983 } |
| 936 | 984 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1007 break; | 1055 break; |
| 1008 } | 1056 } |
| 1009 | 1057 |
| 1010 bool network_moved = DoTransportIO(); | 1058 bool network_moved = DoTransportIO(); |
| 1011 if (network_moved && next_handshake_state_ == STATE_HANDSHAKE) { | 1059 if (network_moved && next_handshake_state_ == STATE_HANDSHAKE) { |
| 1012 // In general we exit the loop if rv is ERR_IO_PENDING. In this | 1060 // In general we exit the loop if rv is ERR_IO_PENDING. In this |
| 1013 // special case we keep looping even if rv is ERR_IO_PENDING because | 1061 // special case we keep looping even if rv is ERR_IO_PENDING because |
| 1014 // the transport IO may allow DoHandshake to make progress. | 1062 // the transport IO may allow DoHandshake to make progress. |
| 1015 rv = OK; // This causes us to stay in the loop. | 1063 rv = OK; // This causes us to stay in the loop. |
| 1016 } | 1064 } |
| 1065 | |
|
mmenke
2014/07/22 16:24:11
nit: Generally, we don't have extra line breaks a
mshelley
2014/07/23 03:49:56
Done.
| |
| 1017 } while (rv != ERR_IO_PENDING && next_handshake_state_ != STATE_NONE); | 1066 } while (rv != ERR_IO_PENDING && next_handshake_state_ != STATE_NONE); |
| 1067 | |
| 1018 return rv; | 1068 return rv; |
| 1019 } | 1069 } |
| 1020 | 1070 |
| 1021 int SSLClientSocketOpenSSL::DoReadLoop(int result) { | 1071 int SSLClientSocketOpenSSL::DoReadLoop(int result) { |
| 1022 if (result < 0) | 1072 if (result < 0) |
| 1023 return result; | 1073 return result; |
| 1024 | 1074 |
| 1025 bool network_moved; | 1075 bool network_moved; |
| 1026 int rv; | 1076 int rv; |
| 1027 do { | 1077 do { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1109 if (rv >= 0) { | 1159 if (rv >= 0) { |
| 1110 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_RECEIVED, rv, | 1160 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_RECEIVED, rv, |
| 1111 user_read_buf_->data()); | 1161 user_read_buf_->data()); |
| 1112 } | 1162 } |
| 1113 return rv; | 1163 return rv; |
| 1114 } | 1164 } |
| 1115 | 1165 |
| 1116 int SSLClientSocketOpenSSL::DoPayloadWrite() { | 1166 int SSLClientSocketOpenSSL::DoPayloadWrite() { |
| 1117 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); | 1167 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); |
| 1118 int rv = SSL_write(ssl_, user_write_buf_->data(), user_write_buf_len_); | 1168 int rv = SSL_write(ssl_, user_write_buf_->data(), user_write_buf_len_); |
| 1119 | |
| 1120 if (rv >= 0) { | 1169 if (rv >= 0) { |
| 1121 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_SENT, rv, | 1170 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_SENT, rv, |
| 1122 user_write_buf_->data()); | 1171 user_write_buf_->data()); |
| 1123 return rv; | 1172 return rv; |
| 1124 } | 1173 } |
| 1125 | 1174 |
| 1126 int err = SSL_get_error(ssl_, rv); | 1175 int err = SSL_get_error(ssl_, rv); |
| 1127 return MapOpenSSLError(err, err_tracer); | 1176 return MapOpenSSLError(err, err_tracer); |
| 1128 } | 1177 } |
| 1129 | 1178 |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1430 DVLOG(2) << "next protocol: '" << npn_proto_ << "' status: " << npn_status_; | 1479 DVLOG(2) << "next protocol: '" << npn_proto_ << "' status: " << npn_status_; |
| 1431 return SSL_TLSEXT_ERR_OK; | 1480 return SSL_TLSEXT_ERR_OK; |
| 1432 } | 1481 } |
| 1433 | 1482 |
| 1434 scoped_refptr<X509Certificate> | 1483 scoped_refptr<X509Certificate> |
| 1435 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { | 1484 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { |
| 1436 return server_cert_; | 1485 return server_cert_; |
| 1437 } | 1486 } |
| 1438 | 1487 |
| 1439 } // namespace net | 1488 } // namespace net |
| OLD | NEW |