OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/ssl.h> | 10 #include <openssl/ssl.h> |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 } | 757 } |
758 return net_error; | 758 return net_error; |
759 } | 759 } |
760 | 760 |
761 int SSLClientSocketOpenSSL::SelectNextProtoCallback(unsigned char** out, | 761 int SSLClientSocketOpenSSL::SelectNextProtoCallback(unsigned char** out, |
762 unsigned char* outlen, | 762 unsigned char* outlen, |
763 const unsigned char* in, | 763 const unsigned char* in, |
764 unsigned int inlen) { | 764 unsigned int inlen) { |
765 #if defined(OPENSSL_NPN_NEGOTIATED) | 765 #if defined(OPENSSL_NPN_NEGOTIATED) |
766 if (ssl_config_.next_protos.empty()) { | 766 if (ssl_config_.next_protos.empty()) { |
767 *out = "http/1.1"; | 767 *out = reinterpret_cast<uint8*>(const_cast<char*>("http/1.1")); |
768 *outlen = 8; | 768 *outlen = 8; |
769 npn_status_ = SSLClientSocket::kNextProtoUnsupported; | 769 npn_status_ = SSLClientSocket::kNextProtoUnsupported; |
770 return SSL_TLSEXT_ERR_OK; | 770 return SSL_TLSEXT_ERR_OK; |
771 } | 771 } |
772 | 772 |
773 int status = SSL_select_next_proto( | 773 int status = SSL_select_next_proto( |
774 out, outlen, in, inlen, | 774 out, outlen, in, inlen, |
775 reinterpret_cast<const unsigned char*>(ssl_config_.next_protos.data()), | 775 reinterpret_cast<const unsigned char*>(ssl_config_.next_protos.data()), |
776 ssl_config_.next_protos.size()); | 776 ssl_config_.next_protos.size()); |
777 | 777 |
778 npn_proto_.assign(reinterpret_cast<const char*>(*out), *outlen); | 778 npn_proto_.assign(reinterpret_cast<const char*>(*out), *outlen); |
779 switch (status) { | 779 switch (status) { |
780 case OPENSSL_NPN_UNSUPPORTED: | 780 case OPENSSL_NPN_UNSUPPORTED: |
781 npn_status_ = SSLClientSocket::kNextProtoUnsupported; | 781 npn_status_ = SSLClientSocket::kNextProtoUnsupported; |
782 break; | 782 break; |
783 case OPENSSL_NPN_NEGOTIATED: | 783 case OPENSSL_NPN_NEGOTIATED: |
784 npn_status_ = SSLClientSocket::kNextProtoNegotiated; | 784 npn_status_ = SSLClientSocket::kNextProtoNegotiated; |
785 break; | 785 break; |
786 case OPENSSL_NPN_NO_OVERLAP: | 786 case OPENSSL_NPN_NO_OVERLAP: |
787 npn_status_ = SSLClientSocket::kNextProtoNoOverlap; | 787 npn_status_ = SSLClientSocket::kNextProtoNoOverlap; |
788 break; | 788 break; |
789 default: | 789 default: |
790 NOTREACHED() << status; | 790 NOTREACHED() << status; |
791 break; | 791 break; |
792 } | 792 } |
| 793 DVLOG(2) << "next protocol: '" << npn_proto_ << "' status: " << npn_status_; |
793 #endif | 794 #endif |
794 return SSL_TLSEXT_ERR_OK; | 795 return SSL_TLSEXT_ERR_OK; |
795 } | 796 } |
796 | 797 |
797 int SSLClientSocketOpenSSL::DoVerifyCert(int result) { | 798 int SSLClientSocketOpenSSL::DoVerifyCert(int result) { |
798 DCHECK(server_cert_); | 799 DCHECK(server_cert_); |
799 GotoState(STATE_VERIFY_CERT_COMPLETE); | 800 GotoState(STATE_VERIFY_CERT_COMPLETE); |
800 int flags = 0; | 801 int flags = 0; |
801 | 802 |
802 if (ssl_config_.rev_checking_enabled) | 803 if (ssl_config_.rev_checking_enabled) |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1171 int rv = SSL_write(ssl_, user_write_buf_->data(), user_write_buf_len_); | 1172 int rv = SSL_write(ssl_, user_write_buf_->data(), user_write_buf_len_); |
1172 | 1173 |
1173 if (rv >= 0) | 1174 if (rv >= 0) |
1174 return rv; | 1175 return rv; |
1175 | 1176 |
1176 int err = SSL_get_error(ssl_, rv); | 1177 int err = SSL_get_error(ssl_, rv); |
1177 return MapOpenSSLError(err, err_tracer); | 1178 return MapOpenSSLError(err, err_tracer); |
1178 } | 1179 } |
1179 | 1180 |
1180 } // namespace net | 1181 } // namespace net |
OLD | NEW |