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 <errno.h> | 10 #include <errno.h> |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 return SSL_CONNECTION_VERSION_TLS1; | 88 return SSL_CONNECTION_VERSION_TLS1; |
89 case 0x0302: | 89 case 0x0302: |
90 return SSL_CONNECTION_VERSION_TLS1_1; | 90 return SSL_CONNECTION_VERSION_TLS1_1; |
91 case 0x0303: | 91 case 0x0303: |
92 return SSL_CONNECTION_VERSION_TLS1_2; | 92 return SSL_CONNECTION_VERSION_TLS1_2; |
93 default: | 93 default: |
94 return SSL_CONNECTION_VERSION_UNKNOWN; | 94 return SSL_CONNECTION_VERSION_UNKNOWN; |
95 } | 95 } |
96 } | 96 } |
97 | 97 |
98 // Compute a unique key string for the SSL session cache. |socket| is an | |
99 // input socket object. Return a string. | |
100 std::string GetSocketSessionCacheKey(const SSLClientSocketOpenSSL& socket) { | |
101 std::string result = socket.host_and_port().ToString(); | |
102 result.append("/"); | |
103 result.append(socket.ssl_session_cache_shard()); | |
104 return result; | |
105 } | |
106 | |
107 void FreeX509Stack(STACK_OF(X509) * ptr) { | 98 void FreeX509Stack(STACK_OF(X509) * ptr) { |
108 sk_X509_pop_free(ptr, X509_free); | 99 sk_X509_pop_free(ptr, X509_free); |
109 } | 100 } |
110 | 101 |
111 ScopedX509 OSCertHandleToOpenSSL( | 102 ScopedX509 OSCertHandleToOpenSSL( |
112 X509Certificate::OSCertHandle os_handle) { | 103 X509Certificate::OSCertHandle os_handle) { |
113 #if defined(USE_OPENSSL_CERTS) | 104 #if defined(USE_OPENSSL_CERTS) |
114 return ScopedX509(X509Certificate::DupOSCertHandle(os_handle)); | 105 return ScopedX509(X509Certificate::DupOSCertHandle(os_handle)); |
115 #else // !defined(USE_OPENSSL_CERTS) | 106 #else // !defined(USE_OPENSSL_CERTS) |
116 std::string der_encoded; | 107 std::string der_encoded; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 // It would be better if the callback were not a global setting, | 148 // It would be better if the callback were not a global setting, |
158 // but that is an OpenSSL issue. | 149 // but that is an OpenSSL issue. |
159 SSL_CTX_set_next_proto_select_cb(ssl_ctx_.get(), SelectNextProtoCallback, | 150 SSL_CTX_set_next_proto_select_cb(ssl_ctx_.get(), SelectNextProtoCallback, |
160 NULL); | 151 NULL); |
161 ssl_ctx_->tlsext_channel_id_enabled_new = 1; | 152 ssl_ctx_->tlsext_channel_id_enabled_new = 1; |
162 } | 153 } |
163 | 154 |
164 static std::string GetSessionCacheKey(const SSL* ssl) { | 155 static std::string GetSessionCacheKey(const SSL* ssl) { |
165 SSLClientSocketOpenSSL* socket = GetInstance()->GetClientSocketFromSSL(ssl); | 156 SSLClientSocketOpenSSL* socket = GetInstance()->GetClientSocketFromSSL(ssl); |
166 DCHECK(socket); | 157 DCHECK(socket); |
167 return GetSocketSessionCacheKey(*socket); | 158 return socket->GetSessionCacheKey(); |
168 } | 159 } |
169 | 160 |
170 static SSLSessionCacheOpenSSL::Config kDefaultSessionCacheConfig; | 161 static SSLSessionCacheOpenSSL::Config kDefaultSessionCacheConfig; |
171 | 162 |
172 static int ClientCertCallback(SSL* ssl, X509** x509, EVP_PKEY** pkey) { | 163 static int ClientCertCallback(SSL* ssl, X509** x509, EVP_PKEY** pkey) { |
173 SSLClientSocketOpenSSL* socket = GetInstance()->GetClientSocketFromSSL(ssl); | 164 SSLClientSocketOpenSSL* socket = GetInstance()->GetClientSocketFromSSL(ssl); |
174 CHECK(socket); | 165 CHECK(socket); |
175 return socket->ClientCertRequestCallback(ssl, x509, pkey); | 166 return socket->ClientCertRequestCallback(ssl, x509, pkey); |
176 } | 167 } |
177 | 168 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 ssl_(NULL), | 356 ssl_(NULL), |
366 transport_bio_(NULL), | 357 transport_bio_(NULL), |
367 transport_(transport_socket.Pass()), | 358 transport_(transport_socket.Pass()), |
368 host_and_port_(host_and_port), | 359 host_and_port_(host_and_port), |
369 ssl_config_(ssl_config), | 360 ssl_config_(ssl_config), |
370 ssl_session_cache_shard_(context.ssl_session_cache_shard), | 361 ssl_session_cache_shard_(context.ssl_session_cache_shard), |
371 trying_cached_session_(false), | 362 trying_cached_session_(false), |
372 next_handshake_state_(STATE_NONE), | 363 next_handshake_state_(STATE_NONE), |
373 npn_status_(kNextProtoUnsupported), | 364 npn_status_(kNextProtoUnsupported), |
374 channel_id_xtn_negotiated_(false), | 365 channel_id_xtn_negotiated_(false), |
375 net_log_(transport_->socket()->NetLog()) {} | 366 net_log_(transport_->socket()->NetLog()) { |
| 367 } |
376 | 368 |
377 SSLClientSocketOpenSSL::~SSLClientSocketOpenSSL() { | 369 SSLClientSocketOpenSSL::~SSLClientSocketOpenSSL() { |
378 Disconnect(); | 370 Disconnect(); |
379 } | 371 } |
380 | 372 |
| 373 bool SSLClientSocketOpenSSL::InSessionCache() const { |
| 374 SSLContext* context = SSLContext::GetInstance(); |
| 375 std::string cache_key = GetSessionCacheKey(); |
| 376 return context->session_cache()->SSLSessionIsInCache(cache_key); |
| 377 } |
| 378 |
| 379 void SSLClientSocketOpenSSL::SetHandshakeCompletionCallback( |
| 380 const base::Closure& callback) { |
| 381 handshake_completion_callback_ = callback; |
| 382 } |
| 383 |
381 void SSLClientSocketOpenSSL::GetSSLCertRequestInfo( | 384 void SSLClientSocketOpenSSL::GetSSLCertRequestInfo( |
382 SSLCertRequestInfo* cert_request_info) { | 385 SSLCertRequestInfo* cert_request_info) { |
383 cert_request_info->host_and_port = host_and_port_; | 386 cert_request_info->host_and_port = host_and_port_; |
384 cert_request_info->cert_authorities = cert_authorities_; | 387 cert_request_info->cert_authorities = cert_authorities_; |
385 cert_request_info->cert_key_types = cert_key_types_; | 388 cert_request_info->cert_key_types = cert_key_types_; |
386 } | 389 } |
387 | 390 |
388 SSLClientSocket::NextProtoStatus SSLClientSocketOpenSSL::GetNextProto( | 391 SSLClientSocket::NextProtoStatus SSLClientSocketOpenSSL::GetNextProto( |
389 std::string* proto) { | 392 std::string* proto) { |
390 *proto = npn_proto_; | 393 *proto = npn_proto_; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 int SSLClientSocketOpenSSL::Connect(const CompletionCallback& callback) { | 428 int SSLClientSocketOpenSSL::Connect(const CompletionCallback& callback) { |
426 net_log_.BeginEvent(NetLog::TYPE_SSL_CONNECT); | 429 net_log_.BeginEvent(NetLog::TYPE_SSL_CONNECT); |
427 | 430 |
428 // Set up new ssl object. | 431 // Set up new ssl object. |
429 int rv = Init(); | 432 int rv = Init(); |
430 if (rv != OK) { | 433 if (rv != OK) { |
431 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); | 434 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); |
432 return rv; | 435 return rv; |
433 } | 436 } |
434 | 437 |
| 438 if (!handshake_completion_callback_.is_null()) { |
| 439 SSLContext* context = SSLContext::GetInstance(); |
| 440 context->session_cache()->SetSessionAddedCallback( |
| 441 ssl_, |
| 442 base::Bind(&SSLClientSocketOpenSSL::OnHandshakeCompletion, |
| 443 base::Unretained(this))); |
| 444 } |
| 445 |
435 // Set SSL to client mode. Handshake happens in the loop below. | 446 // Set SSL to client mode. Handshake happens in the loop below. |
436 SSL_set_connect_state(ssl_); | 447 SSL_set_connect_state(ssl_); |
437 | 448 |
438 GotoState(STATE_HANDSHAKE); | 449 GotoState(STATE_HANDSHAKE); |
439 rv = DoHandshakeLoop(OK); | 450 rv = DoHandshakeLoop(OK); |
440 if (rv == ERR_IO_PENDING) { | 451 if (rv == ERR_IO_PENDING) { |
441 user_connect_callback_ = callback; | 452 user_connect_callback_ = callback; |
442 } else { | 453 } else { |
443 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); | 454 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); |
| 455 if (rv < OK) |
| 456 OnHandshakeCompletion(); |
444 } | 457 } |
445 | 458 |
446 return rv > OK ? OK : rv; | 459 return rv > OK ? OK : rv; |
447 } | 460 } |
448 | 461 |
449 void SSLClientSocketOpenSSL::Disconnect() { | 462 void SSLClientSocketOpenSSL::Disconnect() { |
| 463 // If a handshake was pending (Connect() had been called), notify interested |
| 464 // parties that it's been aborted now. If the handshake had already |
| 465 // completed, this is a no-op. |
| 466 OnHandshakeCompletion(); |
450 if (ssl_) { | 467 if (ssl_) { |
| 468 SSLContext* context = SSLContext::GetInstance(); |
| 469 context->session_cache()->RemoveSessionAddedCallback(ssl_); |
451 // Calling SSL_shutdown prevents the session from being marked as | 470 // Calling SSL_shutdown prevents the session from being marked as |
452 // unresumable. | 471 // unresumable. |
453 SSL_shutdown(ssl_); | 472 SSL_shutdown(ssl_); |
454 SSL_free(ssl_); | 473 SSL_free(ssl_); |
455 ssl_ = NULL; | 474 ssl_ = NULL; |
456 } | 475 } |
457 if (transport_bio_) { | 476 if (transport_bio_) { |
458 BIO_free_all(transport_bio_); | 477 BIO_free_all(transport_bio_); |
459 transport_bio_ = NULL; | 478 transport_bio_ = NULL; |
460 } | 479 } |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 | 637 |
619 int rv = DoReadLoop(OK); | 638 int rv = DoReadLoop(OK); |
620 | 639 |
621 if (rv == ERR_IO_PENDING) { | 640 if (rv == ERR_IO_PENDING) { |
622 user_read_callback_ = callback; | 641 user_read_callback_ = callback; |
623 } else { | 642 } else { |
624 if (rv > 0) | 643 if (rv > 0) |
625 was_ever_used_ = true; | 644 was_ever_used_ = true; |
626 user_read_buf_ = NULL; | 645 user_read_buf_ = NULL; |
627 user_read_buf_len_ = 0; | 646 user_read_buf_len_ = 0; |
| 647 if (rv <= 0) { |
| 648 // Failure of a read attempt may indicate a failed false start |
| 649 // connection. |
| 650 OnHandshakeCompletion(); |
| 651 } |
628 } | 652 } |
629 | 653 |
630 return rv; | 654 return rv; |
631 } | 655 } |
632 | 656 |
633 int SSLClientSocketOpenSSL::Write(IOBuffer* buf, | 657 int SSLClientSocketOpenSSL::Write(IOBuffer* buf, |
634 int buf_len, | 658 int buf_len, |
635 const CompletionCallback& callback) { | 659 const CompletionCallback& callback) { |
636 user_write_buf_ = buf; | 660 user_write_buf_ = buf; |
637 user_write_buf_len_ = buf_len; | 661 user_write_buf_len_ = buf_len; |
638 | 662 |
639 int rv = DoWriteLoop(OK); | 663 int rv = DoWriteLoop(OK); |
640 | 664 |
641 if (rv == ERR_IO_PENDING) { | 665 if (rv == ERR_IO_PENDING) { |
642 user_write_callback_ = callback; | 666 user_write_callback_ = callback; |
643 } else { | 667 } else { |
644 if (rv > 0) | 668 if (rv > 0) |
645 was_ever_used_ = true; | 669 was_ever_used_ = true; |
646 user_write_buf_ = NULL; | 670 user_write_buf_ = NULL; |
647 user_write_buf_len_ = 0; | 671 user_write_buf_len_ = 0; |
| 672 if (rv < 0) { |
| 673 // Failure of a write attempt may indicate a failed false start |
| 674 // connection. |
| 675 OnHandshakeCompletion(); |
| 676 } |
648 } | 677 } |
649 | 678 |
650 return rv; | 679 return rv; |
651 } | 680 } |
652 | 681 |
653 int SSLClientSocketOpenSSL::SetReceiveBufferSize(int32 size) { | 682 int SSLClientSocketOpenSSL::SetReceiveBufferSize(int32 size) { |
654 return transport_->socket()->SetReceiveBufferSize(size); | 683 return transport_->socket()->SetReceiveBufferSize(size); |
655 } | 684 } |
656 | 685 |
657 int SSLClientSocketOpenSSL::SetSendBufferSize(int32 size) { | 686 int SSLClientSocketOpenSSL::SetSendBufferSize(int32 size) { |
658 return transport_->socket()->SetSendBufferSize(size); | 687 return transport_->socket()->SetSendBufferSize(size); |
659 } | 688 } |
660 | 689 |
661 int SSLClientSocketOpenSSL::Init() { | 690 int SSLClientSocketOpenSSL::Init() { |
662 DCHECK(!ssl_); | 691 DCHECK(!ssl_); |
663 DCHECK(!transport_bio_); | 692 DCHECK(!transport_bio_); |
664 | 693 |
665 SSLContext* context = SSLContext::GetInstance(); | 694 SSLContext* context = SSLContext::GetInstance(); |
666 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); | 695 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); |
667 | 696 |
668 ssl_ = SSL_new(context->ssl_ctx()); | 697 ssl_ = SSL_new(context->ssl_ctx()); |
669 if (!ssl_ || !context->SetClientSocketForSSL(ssl_, this)) | 698 if (!ssl_ || !context->SetClientSocketForSSL(ssl_, this)) |
670 return ERR_UNEXPECTED; | 699 return ERR_UNEXPECTED; |
671 | 700 |
672 if (!SSL_set_tlsext_host_name(ssl_, host_and_port_.host().c_str())) | 701 if (!SSL_set_tlsext_host_name(ssl_, host_and_port_.host().c_str())) |
673 return ERR_UNEXPECTED; | 702 return ERR_UNEXPECTED; |
674 | 703 |
675 trying_cached_session_ = context->session_cache()->SetSSLSessionWithKey( | 704 trying_cached_session_ = context->session_cache()->SetSSLSessionWithKey( |
676 ssl_, GetSocketSessionCacheKey(*this)); | 705 ssl_, GetSessionCacheKey()); |
677 | 706 |
678 BIO* ssl_bio = NULL; | 707 BIO* ssl_bio = NULL; |
679 // 0 => use default buffer sizes. | 708 // 0 => use default buffer sizes. |
680 if (!BIO_new_bio_pair(&ssl_bio, 0, &transport_bio_, 0)) | 709 if (!BIO_new_bio_pair(&ssl_bio, 0, &transport_bio_, 0)) |
681 return ERR_UNEXPECTED; | 710 return ERR_UNEXPECTED; |
682 DCHECK(ssl_bio); | 711 DCHECK(ssl_bio); |
683 DCHECK(transport_bio_); | 712 DCHECK(transport_bio_); |
684 | 713 |
685 // Install a callback on OpenSSL's end to plumb transport errors through. | 714 // Install a callback on OpenSSL's end to plumb transport errors through. |
686 BIO_set_callback(ssl_bio, &SSLClientSocketOpenSSL::BIOCallback); | 715 BIO_set_callback(ssl_bio, &SSLClientSocketOpenSSL::BIOCallback); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 return OK; | 813 return OK; |
785 } | 814 } |
786 | 815 |
787 void SSLClientSocketOpenSSL::DoReadCallback(int rv) { | 816 void SSLClientSocketOpenSSL::DoReadCallback(int rv) { |
788 // Since Run may result in Read being called, clear |user_read_callback_| | 817 // Since Run may result in Read being called, clear |user_read_callback_| |
789 // up front. | 818 // up front. |
790 if (rv > 0) | 819 if (rv > 0) |
791 was_ever_used_ = true; | 820 was_ever_used_ = true; |
792 user_read_buf_ = NULL; | 821 user_read_buf_ = NULL; |
793 user_read_buf_len_ = 0; | 822 user_read_buf_len_ = 0; |
| 823 if (rv <= 0) { |
| 824 // Failure of a read attempt may indicate a failed false start |
| 825 // connection. |
| 826 OnHandshakeCompletion(); |
| 827 } |
794 base::ResetAndReturn(&user_read_callback_).Run(rv); | 828 base::ResetAndReturn(&user_read_callback_).Run(rv); |
795 } | 829 } |
796 | 830 |
797 void SSLClientSocketOpenSSL::DoWriteCallback(int rv) { | 831 void SSLClientSocketOpenSSL::DoWriteCallback(int rv) { |
798 // Since Run may result in Write being called, clear |user_write_callback_| | 832 // Since Run may result in Write being called, clear |user_write_callback_| |
799 // up front. | 833 // up front. |
800 if (rv > 0) | 834 if (rv > 0) |
801 was_ever_used_ = true; | 835 was_ever_used_ = true; |
802 user_write_buf_ = NULL; | 836 user_write_buf_ = NULL; |
803 user_write_buf_len_ = 0; | 837 user_write_buf_len_ = 0; |
| 838 if (rv < 0) { |
| 839 // Failure of a write attempt may indicate a failed false start |
| 840 // connection. |
| 841 OnHandshakeCompletion(); |
| 842 } |
804 base::ResetAndReturn(&user_write_callback_).Run(rv); | 843 base::ResetAndReturn(&user_write_callback_).Run(rv); |
805 } | 844 } |
806 | 845 |
| 846 std::string SSLClientSocketOpenSSL::GetSessionCacheKey() const { |
| 847 return CreateSessionCacheKey(host_and_port_, ssl_session_cache_shard_); |
| 848 } |
| 849 |
| 850 void SSLClientSocketOpenSSL::OnHandshakeCompletion() { |
| 851 if (!handshake_completion_callback_.is_null()) |
| 852 base::ResetAndReturn(&handshake_completion_callback_).Run(); |
| 853 } |
| 854 |
807 bool SSLClientSocketOpenSSL::DoTransportIO() { | 855 bool SSLClientSocketOpenSSL::DoTransportIO() { |
808 bool network_moved = false; | 856 bool network_moved = false; |
809 int rv; | 857 int rv; |
810 // Read and write as much data as possible. The loop is necessary because | 858 // Read and write as much data as possible. The loop is necessary because |
811 // Write() may return synchronously. | 859 // Write() may return synchronously. |
812 do { | 860 do { |
813 rv = BufferSend(); | 861 rv = BufferSend(); |
814 if (rv != ERR_IO_PENDING && rv != 0) | 862 if (rv != ERR_IO_PENDING && rv != 0) |
815 network_moved = true; | 863 network_moved = true; |
816 } while (rv > 0); | 864 } while (rv > 0); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 << " (" << result << ")"; | 1037 << " (" << result << ")"; |
990 } | 1038 } |
991 | 1039 |
992 completed_handshake_ = true; | 1040 completed_handshake_ = true; |
993 // Exit DoHandshakeLoop and return the result to the caller to Connect. | 1041 // Exit DoHandshakeLoop and return the result to the caller to Connect. |
994 DCHECK_EQ(STATE_NONE, next_handshake_state_); | 1042 DCHECK_EQ(STATE_NONE, next_handshake_state_); |
995 return result; | 1043 return result; |
996 } | 1044 } |
997 | 1045 |
998 void SSLClientSocketOpenSSL::DoConnectCallback(int rv) { | 1046 void SSLClientSocketOpenSSL::DoConnectCallback(int rv) { |
| 1047 if (rv < OK) |
| 1048 OnHandshakeCompletion(); |
999 if (!user_connect_callback_.is_null()) { | 1049 if (!user_connect_callback_.is_null()) { |
1000 CompletionCallback c = user_connect_callback_; | 1050 CompletionCallback c = user_connect_callback_; |
1001 user_connect_callback_.Reset(); | 1051 user_connect_callback_.Reset(); |
1002 c.Run(rv > OK ? OK : rv); | 1052 c.Run(rv > OK ? OK : rv); |
1003 } | 1053 } |
1004 } | 1054 } |
1005 | 1055 |
1006 X509Certificate* SSLClientSocketOpenSSL::UpdateServerCert() { | 1056 X509Certificate* SSLClientSocketOpenSSL::UpdateServerCert() { |
1007 server_cert_chain_->Reset(SSL_get_peer_cert_chain(ssl_)); | 1057 server_cert_chain_->Reset(SSL_get_peer_cert_chain(ssl_)); |
1008 server_cert_ = server_cert_chain_->AsOSChain(); | 1058 server_cert_ = server_cert_chain_->AsOSChain(); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 } | 1159 } |
1110 | 1160 |
1111 bool network_moved = DoTransportIO(); | 1161 bool network_moved = DoTransportIO(); |
1112 if (network_moved && next_handshake_state_ == STATE_HANDSHAKE) { | 1162 if (network_moved && next_handshake_state_ == STATE_HANDSHAKE) { |
1113 // In general we exit the loop if rv is ERR_IO_PENDING. In this | 1163 // In general we exit the loop if rv is ERR_IO_PENDING. In this |
1114 // special case we keep looping even if rv is ERR_IO_PENDING because | 1164 // special case we keep looping even if rv is ERR_IO_PENDING because |
1115 // the transport IO may allow DoHandshake to make progress. | 1165 // the transport IO may allow DoHandshake to make progress. |
1116 rv = OK; // This causes us to stay in the loop. | 1166 rv = OK; // This causes us to stay in the loop. |
1117 } | 1167 } |
1118 } while (rv != ERR_IO_PENDING && next_handshake_state_ != STATE_NONE); | 1168 } while (rv != ERR_IO_PENDING && next_handshake_state_ != STATE_NONE); |
| 1169 |
1119 return rv; | 1170 return rv; |
1120 } | 1171 } |
1121 | 1172 |
1122 int SSLClientSocketOpenSSL::DoReadLoop(int result) { | 1173 int SSLClientSocketOpenSSL::DoReadLoop(int result) { |
1123 if (result < 0) | 1174 if (result < 0) |
1124 return result; | 1175 return result; |
1125 | 1176 |
1126 bool network_moved; | 1177 bool network_moved; |
1127 int rv; | 1178 int rv; |
1128 do { | 1179 do { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 if (rv >= 0) { | 1261 if (rv >= 0) { |
1211 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_RECEIVED, rv, | 1262 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_RECEIVED, rv, |
1212 user_read_buf_->data()); | 1263 user_read_buf_->data()); |
1213 } | 1264 } |
1214 return rv; | 1265 return rv; |
1215 } | 1266 } |
1216 | 1267 |
1217 int SSLClientSocketOpenSSL::DoPayloadWrite() { | 1268 int SSLClientSocketOpenSSL::DoPayloadWrite() { |
1218 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); | 1269 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); |
1219 int rv = SSL_write(ssl_, user_write_buf_->data(), user_write_buf_len_); | 1270 int rv = SSL_write(ssl_, user_write_buf_->data(), user_write_buf_len_); |
1220 | |
1221 if (rv >= 0) { | 1271 if (rv >= 0) { |
1222 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_SENT, rv, | 1272 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_SENT, rv, |
1223 user_write_buf_->data()); | 1273 user_write_buf_->data()); |
1224 return rv; | 1274 return rv; |
1225 } | 1275 } |
1226 | 1276 |
1227 int err = SSL_get_error(ssl_, rv); | 1277 int err = SSL_get_error(ssl_, rv); |
1228 return MapOpenSSLError(err, err_tracer); | 1278 return MapOpenSSLError(err, err_tracer); |
1229 } | 1279 } |
1230 | 1280 |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1539 return socket->MaybeReplayTransportError( | 1589 return socket->MaybeReplayTransportError( |
1540 bio, cmd, argp, argi, argl, retvalue); | 1590 bio, cmd, argp, argi, argl, retvalue); |
1541 } | 1591 } |
1542 | 1592 |
1543 scoped_refptr<X509Certificate> | 1593 scoped_refptr<X509Certificate> |
1544 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { | 1594 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { |
1545 return server_cert_; | 1595 return server_cert_; |
1546 } | 1596 } |
1547 | 1597 |
1548 } // namespace net | 1598 } // namespace net |
OLD | NEW |