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::SetHandshakeCompletionCallback( | |
368 const base::Closure& callback) { | |
369 handshake_completion_callback_ = callback; | |
370 } | |
371 | |
369 void SSLClientSocketOpenSSL::GetSSLCertRequestInfo( | 372 void SSLClientSocketOpenSSL::GetSSLCertRequestInfo( |
370 SSLCertRequestInfo* cert_request_info) { | 373 SSLCertRequestInfo* cert_request_info) { |
371 cert_request_info->host_and_port = host_and_port_; | 374 cert_request_info->host_and_port = host_and_port_; |
372 cert_request_info->cert_authorities = cert_authorities_; | 375 cert_request_info->cert_authorities = cert_authorities_; |
373 cert_request_info->cert_key_types = cert_key_types_; | 376 cert_request_info->cert_key_types = cert_key_types_; |
374 } | 377 } |
375 | 378 |
376 SSLClientSocket::NextProtoStatus SSLClientSocketOpenSSL::GetNextProto( | 379 SSLClientSocket::NextProtoStatus SSLClientSocketOpenSSL::GetNextProto( |
377 std::string* proto, std::string* server_protos) { | 380 std::string* proto, std::string* server_protos) { |
378 *proto = npn_proto_; | 381 *proto = npn_proto_; |
(...skipping 30 matching lines...) Expand all Loading... | |
409 int SSLClientSocketOpenSSL::GetTLSUniqueChannelBinding(std::string* out) { | 412 int SSLClientSocketOpenSSL::GetTLSUniqueChannelBinding(std::string* out) { |
410 NOTIMPLEMENTED(); | 413 NOTIMPLEMENTED(); |
411 return ERR_NOT_IMPLEMENTED; | 414 return ERR_NOT_IMPLEMENTED; |
412 } | 415 } |
413 | 416 |
414 int SSLClientSocketOpenSSL::Connect(const CompletionCallback& callback) { | 417 int SSLClientSocketOpenSSL::Connect(const CompletionCallback& callback) { |
415 net_log_.BeginEvent(NetLog::TYPE_SSL_CONNECT); | 418 net_log_.BeginEvent(NetLog::TYPE_SSL_CONNECT); |
416 | 419 |
417 // Set up new ssl object. | 420 // Set up new ssl object. |
418 int rv = Init(); | 421 int rv = Init(); |
422 | |
423 if (!handshake_completion_callback_.is_null()) { | |
wtc
2014/07/31 02:02:24
1. Don't separate the Init() call from the check f
mshelley
2014/07/31 20:11:37
Init() initializes ssl_, which is what I map to ca
| |
424 SSLContext* context = SSLContext::GetInstance(); | |
425 context->session_cache()->SetSessionAddedCallback( | |
426 ssl_, | |
427 base::Bind(&SSLClientSocketOpenSSL::OnHandshakeCompletion, | |
428 base::Unretained(this))); | |
429 } | |
430 | |
419 if (rv != OK) { | 431 if (rv != OK) { |
420 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); | 432 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); |
421 return rv; | 433 return rv; |
422 } | 434 } |
423 | 435 |
424 // Set SSL to client mode. Handshake happens in the loop below. | 436 // Set SSL to client mode. Handshake happens in the loop below. |
425 SSL_set_connect_state(ssl_); | 437 SSL_set_connect_state(ssl_); |
426 | 438 |
427 GotoState(STATE_HANDSHAKE); | 439 GotoState(STATE_HANDSHAKE); |
428 rv = DoHandshakeLoop(OK); | 440 rv = DoHandshakeLoop(OK); |
429 if (rv == ERR_IO_PENDING) { | 441 if (rv == ERR_IO_PENDING) { |
430 user_connect_callback_ = callback; | 442 user_connect_callback_ = callback; |
431 } else { | 443 } else { |
432 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); | 444 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); |
445 if (rv < OK) | |
446 OnHandshakeCompletion(); | |
433 } | 447 } |
434 | 448 |
435 return rv > OK ? OK : rv; | 449 return rv > OK ? OK : rv; |
436 } | 450 } |
437 | 451 |
438 void SSLClientSocketOpenSSL::Disconnect() { | 452 void SSLClientSocketOpenSSL::Disconnect() { |
453 // If a handshake was pending (Connect() had been called), notify interested | |
454 // parties that it's been aborted now. If the handshake had already completed, f | |
455 // this is a no-op. | |
456 OnHandshakeCompletion(); | |
439 if (ssl_) { | 457 if (ssl_) { |
458 SSLContext* context = SSLContext::GetInstance(); | |
459 context->session_cache()->RemoveSessionAddedCallback(ssl_); | |
440 // Calling SSL_shutdown prevents the session from being marked as | 460 // Calling SSL_shutdown prevents the session from being marked as |
441 // unresumable. | 461 // unresumable. |
442 SSL_shutdown(ssl_); | 462 SSL_shutdown(ssl_); |
443 SSL_free(ssl_); | 463 SSL_free(ssl_); |
444 ssl_ = NULL; | 464 ssl_ = NULL; |
445 } | 465 } |
446 if (transport_bio_) { | 466 if (transport_bio_) { |
447 BIO_free_all(transport_bio_); | 467 BIO_free_all(transport_bio_); |
448 transport_bio_ = NULL; | 468 transport_bio_ = NULL; |
449 } | 469 } |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
603 | 623 |
604 int rv = DoReadLoop(OK); | 624 int rv = DoReadLoop(OK); |
605 | 625 |
606 if (rv == ERR_IO_PENDING) { | 626 if (rv == ERR_IO_PENDING) { |
607 user_read_callback_ = callback; | 627 user_read_callback_ = callback; |
608 } else { | 628 } else { |
609 if (rv > 0) | 629 if (rv > 0) |
610 was_ever_used_ = true; | 630 was_ever_used_ = true; |
611 user_read_buf_ = NULL; | 631 user_read_buf_ = NULL; |
612 user_read_buf_len_ = 0; | 632 user_read_buf_len_ = 0; |
633 if (rv <= 0) { | |
634 // Failure of a read attempt may indicate a failed false start | |
635 // connection. | |
636 OnHandshakeCompletion(); | |
637 } | |
613 } | 638 } |
614 | 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; |
658 if (rv < 0) { | |
659 // Failure of a write attempt may indicate a failed false start | |
660 // connection. | |
661 OnHandshakeCompletion(); | |
662 } | |
633 } | 663 } |
634 | 664 |
635 return rv; | 665 return rv; |
636 } | 666 } |
637 | 667 |
638 int SSLClientSocketOpenSSL::SetReceiveBufferSize(int32 size) { | 668 int SSLClientSocketOpenSSL::SetReceiveBufferSize(int32 size) { |
639 return transport_->socket()->SetReceiveBufferSize(size); | 669 return transport_->socket()->SetReceiveBufferSize(size); |
640 } | 670 } |
641 | 671 |
642 int SSLClientSocketOpenSSL::SetSendBufferSize(int32 size) { | 672 int SSLClientSocketOpenSSL::SetSendBufferSize(int32 size) { |
643 return transport_->socket()->SetSendBufferSize(size); | 673 return transport_->socket()->SetSendBufferSize(size); |
644 } | 674 } |
645 | 675 |
646 int SSLClientSocketOpenSSL::Init() { | 676 int SSLClientSocketOpenSSL::Init() { |
647 DCHECK(!ssl_); | 677 DCHECK(!ssl_); |
648 DCHECK(!transport_bio_); | 678 DCHECK(!transport_bio_); |
649 | 679 |
650 SSLContext* context = SSLContext::GetInstance(); | 680 SSLContext* context = SSLContext::GetInstance(); |
651 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); | 681 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); |
652 | 682 |
653 ssl_ = SSL_new(context->ssl_ctx()); | 683 ssl_ = SSL_new(context->ssl_ctx()); |
654 if (!ssl_ || !context->SetClientSocketForSSL(ssl_, this)) | 684 if (!ssl_ || !context->SetClientSocketForSSL(ssl_, this)) |
655 return ERR_UNEXPECTED; | 685 return ERR_UNEXPECTED; |
656 | 686 |
657 if (!SSL_set_tlsext_host_name(ssl_, host_and_port_.host().c_str())) | 687 if (!SSL_set_tlsext_host_name(ssl_, host_and_port_.host().c_str())) |
658 return ERR_UNEXPECTED; | 688 return ERR_UNEXPECTED; |
659 | 689 |
660 trying_cached_session_ = context->session_cache()->SetSSLSessionWithKey( | 690 trying_cached_session_ = context->session_cache()->SetSSLSessionWithKey( |
661 ssl_, GetSocketSessionCacheKey(*this)); | 691 ssl_, GetSessionCacheKey()); |
662 | 692 |
663 BIO* ssl_bio = NULL; | 693 BIO* ssl_bio = NULL; |
664 // 0 => use default buffer sizes. | 694 // 0 => use default buffer sizes. |
665 if (!BIO_new_bio_pair(&ssl_bio, 0, &transport_bio_, 0)) | 695 if (!BIO_new_bio_pair(&ssl_bio, 0, &transport_bio_, 0)) |
666 return ERR_UNEXPECTED; | 696 return ERR_UNEXPECTED; |
667 DCHECK(ssl_bio); | 697 DCHECK(ssl_bio); |
668 DCHECK(transport_bio_); | 698 DCHECK(transport_bio_); |
669 | 699 |
670 SSL_set_bio(ssl_, ssl_bio, ssl_bio); | 700 SSL_set_bio(ssl_, ssl_bio, ssl_bio); |
671 | 701 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
755 return OK; | 785 return OK; |
756 } | 786 } |
757 | 787 |
758 void SSLClientSocketOpenSSL::DoReadCallback(int rv) { | 788 void SSLClientSocketOpenSSL::DoReadCallback(int rv) { |
759 // Since Run may result in Read being called, clear |user_read_callback_| | 789 // Since Run may result in Read being called, clear |user_read_callback_| |
760 // up front. | 790 // up front. |
761 if (rv > 0) | 791 if (rv > 0) |
762 was_ever_used_ = true; | 792 was_ever_used_ = true; |
763 user_read_buf_ = NULL; | 793 user_read_buf_ = NULL; |
764 user_read_buf_len_ = 0; | 794 user_read_buf_len_ = 0; |
795 if (rv <= 0) { | |
796 // Failure of a read attempt may indicate a failed false start | |
797 // connection. | |
798 OnHandshakeCompletion(); | |
799 } | |
765 base::ResetAndReturn(&user_read_callback_).Run(rv); | 800 base::ResetAndReturn(&user_read_callback_).Run(rv); |
766 } | 801 } |
767 | 802 |
768 void SSLClientSocketOpenSSL::DoWriteCallback(int rv) { | 803 void SSLClientSocketOpenSSL::DoWriteCallback(int rv) { |
769 // Since Run may result in Write being called, clear |user_write_callback_| | 804 // Since Run may result in Write being called, clear |user_write_callback_| |
770 // up front. | 805 // up front. |
771 if (rv > 0) | 806 if (rv > 0) |
772 was_ever_used_ = true; | 807 was_ever_used_ = true; |
773 user_write_buf_ = NULL; | 808 user_write_buf_ = NULL; |
774 user_write_buf_len_ = 0; | 809 user_write_buf_len_ = 0; |
810 if (rv < 0) { | |
811 // Failure of a write attempt may indicate a failed false start | |
812 // connection. | |
813 OnHandshakeCompletion(); | |
814 } | |
775 base::ResetAndReturn(&user_write_callback_).Run(rv); | 815 base::ResetAndReturn(&user_write_callback_).Run(rv); |
776 } | 816 } |
777 | 817 |
818 std::string SSLClientSocketOpenSSL::GetSessionCacheKey() const { | |
819 return CreateSessionCacheKey(host_and_port_, ssl_session_cache_shard_); | |
820 } | |
821 | |
822 void SSLClientSocketOpenSSL::OnHandshakeCompletion() { | |
823 if (!handshake_completion_callback_.is_null()) | |
824 base::ResetAndReturn(&handshake_completion_callback_).Run(); | |
825 } | |
826 | |
778 bool SSLClientSocketOpenSSL::DoTransportIO() { | 827 bool SSLClientSocketOpenSSL::DoTransportIO() { |
779 bool network_moved = false; | 828 bool network_moved = false; |
780 int rv; | 829 int rv; |
781 // Read and write as much data as possible. The loop is necessary because | 830 // Read and write as much data as possible. The loop is necessary because |
782 // Write() may return synchronously. | 831 // Write() may return synchronously. |
783 do { | 832 do { |
784 rv = BufferSend(); | 833 rv = BufferSend(); |
785 if (rv != ERR_IO_PENDING && rv != 0) | 834 if (rv != ERR_IO_PENDING && rv != 0) |
786 network_moved = true; | 835 network_moved = true; |
787 } while (rv > 0); | 836 } while (rv > 0); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
895 << " (" << result << ")"; | 944 << " (" << result << ")"; |
896 } | 945 } |
897 | 946 |
898 completed_handshake_ = true; | 947 completed_handshake_ = true; |
899 // Exit DoHandshakeLoop and return the result to the caller to Connect. | 948 // Exit DoHandshakeLoop and return the result to the caller to Connect. |
900 DCHECK_EQ(STATE_NONE, next_handshake_state_); | 949 DCHECK_EQ(STATE_NONE, next_handshake_state_); |
901 return result; | 950 return result; |
902 } | 951 } |
903 | 952 |
904 void SSLClientSocketOpenSSL::DoConnectCallback(int rv) { | 953 void SSLClientSocketOpenSSL::DoConnectCallback(int rv) { |
954 if (rv < OK) | |
955 OnHandshakeCompletion(); | |
905 if (!user_connect_callback_.is_null()) { | 956 if (!user_connect_callback_.is_null()) { |
906 CompletionCallback c = user_connect_callback_; | 957 CompletionCallback c = user_connect_callback_; |
907 user_connect_callback_.Reset(); | 958 user_connect_callback_.Reset(); |
908 c.Run(rv > OK ? OK : rv); | 959 c.Run(rv > OK ? OK : rv); |
909 } | 960 } |
910 } | 961 } |
911 | 962 |
912 X509Certificate* SSLClientSocketOpenSSL::UpdateServerCert() { | 963 X509Certificate* SSLClientSocketOpenSSL::UpdateServerCert() { |
913 server_cert_chain_->Reset(SSL_get_peer_cert_chain(ssl_)); | 964 server_cert_chain_->Reset(SSL_get_peer_cert_chain(ssl_)); |
914 server_cert_ = server_cert_chain_->AsOSChain(); | 965 server_cert_ = server_cert_chain_->AsOSChain(); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1008 } | 1059 } |
1009 | 1060 |
1010 bool network_moved = DoTransportIO(); | 1061 bool network_moved = DoTransportIO(); |
1011 if (network_moved && next_handshake_state_ == STATE_HANDSHAKE) { | 1062 if (network_moved && next_handshake_state_ == STATE_HANDSHAKE) { |
1012 // In general we exit the loop if rv is ERR_IO_PENDING. In this | 1063 // 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 | 1064 // special case we keep looping even if rv is ERR_IO_PENDING because |
1014 // the transport IO may allow DoHandshake to make progress. | 1065 // the transport IO may allow DoHandshake to make progress. |
1015 rv = OK; // This causes us to stay in the loop. | 1066 rv = OK; // This causes us to stay in the loop. |
1016 } | 1067 } |
1017 } while (rv != ERR_IO_PENDING && next_handshake_state_ != STATE_NONE); | 1068 } while (rv != ERR_IO_PENDING && next_handshake_state_ != STATE_NONE); |
1069 | |
1018 return rv; | 1070 return rv; |
1019 } | 1071 } |
1020 | 1072 |
1021 int SSLClientSocketOpenSSL::DoReadLoop(int result) { | 1073 int SSLClientSocketOpenSSL::DoReadLoop(int result) { |
1022 if (result < 0) | 1074 if (result < 0) |
1023 return result; | 1075 return result; |
1024 | 1076 |
1025 bool network_moved; | 1077 bool network_moved; |
1026 int rv; | 1078 int rv; |
1027 do { | 1079 do { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1109 if (rv >= 0) { | 1161 if (rv >= 0) { |
1110 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_RECEIVED, rv, | 1162 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_RECEIVED, rv, |
1111 user_read_buf_->data()); | 1163 user_read_buf_->data()); |
1112 } | 1164 } |
1113 return rv; | 1165 return rv; |
1114 } | 1166 } |
1115 | 1167 |
1116 int SSLClientSocketOpenSSL::DoPayloadWrite() { | 1168 int SSLClientSocketOpenSSL::DoPayloadWrite() { |
1117 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); | 1169 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); |
1118 int rv = SSL_write(ssl_, user_write_buf_->data(), user_write_buf_len_); | 1170 int rv = SSL_write(ssl_, user_write_buf_->data(), user_write_buf_len_); |
1119 | |
1120 if (rv >= 0) { | 1171 if (rv >= 0) { |
1121 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_SENT, rv, | 1172 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_SENT, rv, |
1122 user_write_buf_->data()); | 1173 user_write_buf_->data()); |
1123 return rv; | 1174 return rv; |
1124 } | 1175 } |
1125 | 1176 |
1126 int err = SSL_get_error(ssl_, rv); | 1177 int err = SSL_get_error(ssl_, rv); |
1127 return MapOpenSSLError(err, err_tracer); | 1178 return MapOpenSSLError(err, err_tracer); |
1128 } | 1179 } |
1129 | 1180 |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1430 DVLOG(2) << "next protocol: '" << npn_proto_ << "' status: " << npn_status_; | 1481 DVLOG(2) << "next protocol: '" << npn_proto_ << "' status: " << npn_status_; |
1431 return SSL_TLSEXT_ERR_OK; | 1482 return SSL_TLSEXT_ERR_OK; |
1432 } | 1483 } |
1433 | 1484 |
1434 scoped_refptr<X509Certificate> | 1485 scoped_refptr<X509Certificate> |
1435 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { | 1486 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { |
1436 return server_cert_; | 1487 return server_cert_; |
1437 } | 1488 } |
1438 | 1489 |
1439 } // namespace net | 1490 } // namespace net |
OLD | NEW |