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 SSLContext* context = SSLContext::GetInstance(); | |
371 context->session_cache()->SetSessionAddedCallback( | |
372 ssl_, | |
373 base::Bind(&SSLClientSocketOpenSSL::OnHandshakeCompletion, | |
374 base::Unretained(this))); | |
375 } | |
376 | |
369 void SSLClientSocketOpenSSL::GetSSLCertRequestInfo( | 377 void SSLClientSocketOpenSSL::GetSSLCertRequestInfo( |
370 SSLCertRequestInfo* cert_request_info) { | 378 SSLCertRequestInfo* cert_request_info) { |
371 cert_request_info->host_and_port = host_and_port_; | 379 cert_request_info->host_and_port = host_and_port_; |
372 cert_request_info->cert_authorities = cert_authorities_; | 380 cert_request_info->cert_authorities = cert_authorities_; |
373 cert_request_info->cert_key_types = cert_key_types_; | 381 cert_request_info->cert_key_types = cert_key_types_; |
374 } | 382 } |
375 | 383 |
376 SSLClientSocket::NextProtoStatus SSLClientSocketOpenSSL::GetNextProto( | 384 SSLClientSocket::NextProtoStatus SSLClientSocketOpenSSL::GetNextProto( |
377 std::string* proto, std::string* server_protos) { | 385 std::string* proto, std::string* server_protos) { |
378 *proto = npn_proto_; | 386 *proto = npn_proto_; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
423 | 431 |
424 // Set SSL to client mode. Handshake happens in the loop below. | 432 // Set SSL to client mode. Handshake happens in the loop below. |
425 SSL_set_connect_state(ssl_); | 433 SSL_set_connect_state(ssl_); |
426 | 434 |
427 GotoState(STATE_HANDSHAKE); | 435 GotoState(STATE_HANDSHAKE); |
428 rv = DoHandshakeLoop(OK); | 436 rv = DoHandshakeLoop(OK); |
429 if (rv == ERR_IO_PENDING) { | 437 if (rv == ERR_IO_PENDING) { |
430 user_connect_callback_ = callback; | 438 user_connect_callback_ = callback; |
431 } else { | 439 } else { |
432 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); | 440 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); |
441 if (rv < OK) | |
442 OnHandshakeCompletion(); | |
433 } | 443 } |
434 | 444 |
435 return rv > OK ? OK : rv; | 445 return rv > OK ? OK : rv; |
436 } | 446 } |
437 | 447 |
438 void SSLClientSocketOpenSSL::Disconnect() { | 448 void SSLClientSocketOpenSSL::Disconnect() { |
449 // OnHandshakeCompletion runs the |handshake_completion_callback_| | |
450 // here to ensure that connections dependant upon this socket's connetion | |
451 // are allowed to resume if this socket is disconnected. | |
Ryan Sleevi
2014/07/29 23:19:22
This comment is a bit of a layering violation. Tha
mshelley
2014/07/30 18:33:54
Done.
| |
452 OnHandshakeCompletion(); | |
439 if (ssl_) { | 453 if (ssl_) { |
454 SSLContext* context = SSLContext::GetInstance(); | |
455 context->session_cache()->RemoveSessionAddedCallback(ssl_); | |
440 // Calling SSL_shutdown prevents the session from being marked as | 456 // Calling SSL_shutdown prevents the session from being marked as |
441 // unresumable. | 457 // unresumable. |
442 SSL_shutdown(ssl_); | 458 SSL_shutdown(ssl_); |
443 SSL_free(ssl_); | 459 SSL_free(ssl_); |
444 ssl_ = NULL; | 460 ssl_ = NULL; |
445 } | 461 } |
446 if (transport_bio_) { | 462 if (transport_bio_) { |
447 BIO_free_all(transport_bio_); | 463 BIO_free_all(transport_bio_); |
448 transport_bio_ = NULL; | 464 transport_bio_ = NULL; |
449 } | 465 } |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
603 | 619 |
604 int rv = DoReadLoop(OK); | 620 int rv = DoReadLoop(OK); |
605 | 621 |
606 if (rv == ERR_IO_PENDING) { | 622 if (rv == ERR_IO_PENDING) { |
607 user_read_callback_ = callback; | 623 user_read_callback_ = callback; |
608 } else { | 624 } else { |
609 if (rv > 0) | 625 if (rv > 0) |
610 was_ever_used_ = true; | 626 was_ever_used_ = true; |
611 user_read_buf_ = NULL; | 627 user_read_buf_ = NULL; |
612 user_read_buf_len_ = 0; | 628 user_read_buf_len_ = 0; |
629 if (rv <= 0) { | |
630 // Failure of a read attempt may indicate a failed false start | |
631 // connection. | |
632 OnHandshakeCompletion(); | |
633 } | |
613 } | 634 } |
614 | 635 |
615 return rv; | 636 return rv; |
616 } | 637 } |
617 | 638 |
618 int SSLClientSocketOpenSSL::Write(IOBuffer* buf, | 639 int SSLClientSocketOpenSSL::Write(IOBuffer* buf, |
619 int buf_len, | 640 int buf_len, |
620 const CompletionCallback& callback) { | 641 const CompletionCallback& callback) { |
621 user_write_buf_ = buf; | 642 user_write_buf_ = buf; |
622 user_write_buf_len_ = buf_len; | 643 user_write_buf_len_ = buf_len; |
623 | 644 |
624 int rv = DoWriteLoop(OK); | 645 int rv = DoWriteLoop(OK); |
625 | 646 |
626 if (rv == ERR_IO_PENDING) { | 647 if (rv == ERR_IO_PENDING) { |
627 user_write_callback_ = callback; | 648 user_write_callback_ = callback; |
628 } else { | 649 } else { |
629 if (rv > 0) | 650 if (rv > 0) |
630 was_ever_used_ = true; | 651 was_ever_used_ = true; |
631 user_write_buf_ = NULL; | 652 user_write_buf_ = NULL; |
632 user_write_buf_len_ = 0; | 653 user_write_buf_len_ = 0; |
654 if (rv < 0) { | |
655 // Failure of a write attempt may indicate a failed false start | |
656 // connection. | |
657 OnHandshakeCompletion(); | |
658 } | |
633 } | 659 } |
634 | 660 |
635 return rv; | 661 return rv; |
636 } | 662 } |
637 | 663 |
638 int SSLClientSocketOpenSSL::SetReceiveBufferSize(int32 size) { | 664 int SSLClientSocketOpenSSL::SetReceiveBufferSize(int32 size) { |
639 return transport_->socket()->SetReceiveBufferSize(size); | 665 return transport_->socket()->SetReceiveBufferSize(size); |
640 } | 666 } |
641 | 667 |
642 int SSLClientSocketOpenSSL::SetSendBufferSize(int32 size) { | 668 int SSLClientSocketOpenSSL::SetSendBufferSize(int32 size) { |
643 return transport_->socket()->SetSendBufferSize(size); | 669 return transport_->socket()->SetSendBufferSize(size); |
644 } | 670 } |
645 | 671 |
646 int SSLClientSocketOpenSSL::Init() { | 672 int SSLClientSocketOpenSSL::Init() { |
647 DCHECK(!ssl_); | 673 DCHECK(!ssl_); |
648 DCHECK(!transport_bio_); | 674 DCHECK(!transport_bio_); |
649 | 675 |
650 SSLContext* context = SSLContext::GetInstance(); | 676 SSLContext* context = SSLContext::GetInstance(); |
651 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); | 677 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); |
652 | 678 |
653 ssl_ = SSL_new(context->ssl_ctx()); | 679 ssl_ = SSL_new(context->ssl_ctx()); |
654 if (!ssl_ || !context->SetClientSocketForSSL(ssl_, this)) | 680 if (!ssl_ || !context->SetClientSocketForSSL(ssl_, this)) |
655 return ERR_UNEXPECTED; | 681 return ERR_UNEXPECTED; |
656 | 682 |
657 if (!SSL_set_tlsext_host_name(ssl_, host_and_port_.host().c_str())) | 683 if (!SSL_set_tlsext_host_name(ssl_, host_and_port_.host().c_str())) |
658 return ERR_UNEXPECTED; | 684 return ERR_UNEXPECTED; |
659 | 685 |
660 trying_cached_session_ = context->session_cache()->SetSSLSessionWithKey( | 686 trying_cached_session_ = context->session_cache()->SetSSLSessionWithKey( |
661 ssl_, GetSocketSessionCacheKey(*this)); | 687 ssl_, GetSessionCacheKey()); |
662 | 688 |
663 BIO* ssl_bio = NULL; | 689 BIO* ssl_bio = NULL; |
664 // 0 => use default buffer sizes. | 690 // 0 => use default buffer sizes. |
665 if (!BIO_new_bio_pair(&ssl_bio, 0, &transport_bio_, 0)) | 691 if (!BIO_new_bio_pair(&ssl_bio, 0, &transport_bio_, 0)) |
666 return ERR_UNEXPECTED; | 692 return ERR_UNEXPECTED; |
667 DCHECK(ssl_bio); | 693 DCHECK(ssl_bio); |
668 DCHECK(transport_bio_); | 694 DCHECK(transport_bio_); |
669 | 695 |
670 SSL_set_bio(ssl_, ssl_bio, ssl_bio); | 696 SSL_set_bio(ssl_, ssl_bio, ssl_bio); |
671 | 697 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
755 return OK; | 781 return OK; |
756 } | 782 } |
757 | 783 |
758 void SSLClientSocketOpenSSL::DoReadCallback(int rv) { | 784 void SSLClientSocketOpenSSL::DoReadCallback(int rv) { |
759 // Since Run may result in Read being called, clear |user_read_callback_| | 785 // Since Run may result in Read being called, clear |user_read_callback_| |
760 // up front. | 786 // up front. |
761 if (rv > 0) | 787 if (rv > 0) |
762 was_ever_used_ = true; | 788 was_ever_used_ = true; |
763 user_read_buf_ = NULL; | 789 user_read_buf_ = NULL; |
764 user_read_buf_len_ = 0; | 790 user_read_buf_len_ = 0; |
791 if (rv <= 0) { | |
792 // Failure of a read attempt may indicate a failed false start | |
793 // connection. | |
794 OnHandshakeCompletion(); | |
795 } | |
765 base::ResetAndReturn(&user_read_callback_).Run(rv); | 796 base::ResetAndReturn(&user_read_callback_).Run(rv); |
766 } | 797 } |
767 | 798 |
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; |
806 if (rv < 0) { | |
807 // Failure of a write attempt may indicate a failed false start | |
808 // connection. | |
809 OnHandshakeCompletion(); | |
810 } | |
775 base::ResetAndReturn(&user_write_callback_).Run(rv); | 811 base::ResetAndReturn(&user_write_callback_).Run(rv); |
776 } | 812 } |
777 | 813 |
814 std::string SSLClientSocketOpenSSL::GetSessionCacheKey() const { | |
815 return CreateSessionCacheKey(host_and_port_, ssl_session_cache_shard_); | |
816 } | |
817 | |
818 void SSLClientSocketOpenSSL::OnHandshakeCompletion() { | |
819 if (!handshake_completion_callback_.is_null()) | |
820 base::ResetAndReturn(&handshake_completion_callback_).Run(); | |
821 } | |
822 | |
778 bool SSLClientSocketOpenSSL::DoTransportIO() { | 823 bool SSLClientSocketOpenSSL::DoTransportIO() { |
779 bool network_moved = false; | 824 bool network_moved = false; |
780 int rv; | 825 int rv; |
781 // Read and write as much data as possible. The loop is necessary because | 826 // Read and write as much data as possible. The loop is necessary because |
782 // Write() may return synchronously. | 827 // Write() may return synchronously. |
783 do { | 828 do { |
784 rv = BufferSend(); | 829 rv = BufferSend(); |
785 if (rv != ERR_IO_PENDING && rv != 0) | 830 if (rv != ERR_IO_PENDING && rv != 0) |
786 network_moved = true; | 831 network_moved = true; |
787 } while (rv > 0); | 832 } while (rv > 0); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
895 << " (" << result << ")"; | 940 << " (" << result << ")"; |
896 } | 941 } |
897 | 942 |
898 completed_handshake_ = true; | 943 completed_handshake_ = true; |
899 // Exit DoHandshakeLoop and return the result to the caller to Connect. | 944 // Exit DoHandshakeLoop and return the result to the caller to Connect. |
900 DCHECK_EQ(STATE_NONE, next_handshake_state_); | 945 DCHECK_EQ(STATE_NONE, next_handshake_state_); |
901 return result; | 946 return result; |
902 } | 947 } |
903 | 948 |
904 void SSLClientSocketOpenSSL::DoConnectCallback(int rv) { | 949 void SSLClientSocketOpenSSL::DoConnectCallback(int rv) { |
950 if (rv < OK) | |
951 OnHandshakeCompletion(); | |
905 if (!user_connect_callback_.is_null()) { | 952 if (!user_connect_callback_.is_null()) { |
906 CompletionCallback c = user_connect_callback_; | 953 CompletionCallback c = user_connect_callback_; |
907 user_connect_callback_.Reset(); | 954 user_connect_callback_.Reset(); |
908 c.Run(rv > OK ? OK : rv); | 955 c.Run(rv > OK ? OK : rv); |
909 } | 956 } |
910 } | 957 } |
911 | 958 |
912 X509Certificate* SSLClientSocketOpenSSL::UpdateServerCert() { | 959 X509Certificate* SSLClientSocketOpenSSL::UpdateServerCert() { |
913 server_cert_chain_->Reset(SSL_get_peer_cert_chain(ssl_)); | 960 server_cert_chain_->Reset(SSL_get_peer_cert_chain(ssl_)); |
914 server_cert_ = server_cert_chain_->AsOSChain(); | 961 server_cert_ = server_cert_chain_->AsOSChain(); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1008 } | 1055 } |
1009 | 1056 |
1010 bool network_moved = DoTransportIO(); | 1057 bool network_moved = DoTransportIO(); |
1011 if (network_moved && next_handshake_state_ == STATE_HANDSHAKE) { | 1058 if (network_moved && next_handshake_state_ == STATE_HANDSHAKE) { |
1012 // In general we exit the loop if rv is ERR_IO_PENDING. In this | 1059 // 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 | 1060 // special case we keep looping even if rv is ERR_IO_PENDING because |
1014 // the transport IO may allow DoHandshake to make progress. | 1061 // the transport IO may allow DoHandshake to make progress. |
1015 rv = OK; // This causes us to stay in the loop. | 1062 rv = OK; // This causes us to stay in the loop. |
1016 } | 1063 } |
1017 } while (rv != ERR_IO_PENDING && next_handshake_state_ != STATE_NONE); | 1064 } while (rv != ERR_IO_PENDING && next_handshake_state_ != STATE_NONE); |
1065 | |
1018 return rv; | 1066 return rv; |
1019 } | 1067 } |
1020 | 1068 |
1021 int SSLClientSocketOpenSSL::DoReadLoop(int result) { | 1069 int SSLClientSocketOpenSSL::DoReadLoop(int result) { |
1022 if (result < 0) | 1070 if (result < 0) |
1023 return result; | 1071 return result; |
1024 | 1072 |
1025 bool network_moved; | 1073 bool network_moved; |
1026 int rv; | 1074 int rv; |
1027 do { | 1075 do { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1109 if (rv >= 0) { | 1157 if (rv >= 0) { |
1110 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_RECEIVED, rv, | 1158 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_RECEIVED, rv, |
1111 user_read_buf_->data()); | 1159 user_read_buf_->data()); |
1112 } | 1160 } |
1113 return rv; | 1161 return rv; |
1114 } | 1162 } |
1115 | 1163 |
1116 int SSLClientSocketOpenSSL::DoPayloadWrite() { | 1164 int SSLClientSocketOpenSSL::DoPayloadWrite() { |
1117 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); | 1165 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); |
1118 int rv = SSL_write(ssl_, user_write_buf_->data(), user_write_buf_len_); | 1166 int rv = SSL_write(ssl_, user_write_buf_->data(), user_write_buf_len_); |
1119 | |
1120 if (rv >= 0) { | 1167 if (rv >= 0) { |
1121 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_SENT, rv, | 1168 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_SENT, rv, |
1122 user_write_buf_->data()); | 1169 user_write_buf_->data()); |
1123 return rv; | 1170 return rv; |
1124 } | 1171 } |
1125 | 1172 |
1126 int err = SSL_get_error(ssl_, rv); | 1173 int err = SSL_get_error(ssl_, rv); |
1127 return MapOpenSSLError(err, err_tracer); | 1174 return MapOpenSSLError(err, err_tracer); |
1128 } | 1175 } |
1129 | 1176 |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1430 DVLOG(2) << "next protocol: '" << npn_proto_ << "' status: " << npn_status_; | 1477 DVLOG(2) << "next protocol: '" << npn_proto_ << "' status: " << npn_status_; |
1431 return SSL_TLSEXT_ERR_OK; | 1478 return SSL_TLSEXT_ERR_OK; |
1432 } | 1479 } |
1433 | 1480 |
1434 scoped_refptr<X509Certificate> | 1481 scoped_refptr<X509Certificate> |
1435 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { | 1482 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { |
1436 return server_cert_; | 1483 return server_cert_; |
1437 } | 1484 } |
1438 | 1485 |
1439 } // namespace net | 1486 } // namespace net |
OLD | NEW |