OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
785 const unsigned char* in, | 785 const unsigned char* in, |
786 unsigned int inlen) { | 786 unsigned int inlen) { |
787 #if defined(OPENSSL_NPN_NEGOTIATED) | 787 #if defined(OPENSSL_NPN_NEGOTIATED) |
788 if (ssl_config_.next_protos.empty()) { | 788 if (ssl_config_.next_protos.empty()) { |
789 *out = reinterpret_cast<uint8*>(const_cast<char*>("http/1.1")); | 789 *out = reinterpret_cast<uint8*>(const_cast<char*>("http/1.1")); |
790 *outlen = 8; | 790 *outlen = 8; |
791 npn_status_ = SSLClientSocket::kNextProtoUnsupported; | 791 npn_status_ = SSLClientSocket::kNextProtoUnsupported; |
792 return SSL_TLSEXT_ERR_OK; | 792 return SSL_TLSEXT_ERR_OK; |
793 } | 793 } |
794 | 794 |
795 int status = SSL_select_next_proto( | 795 int status = OPENSSL_NPN_UNSUPPORTED; |
796 out, outlen, in, inlen, | 796 for (unsigned int i = 0; i < inlen; i++) { |
797 reinterpret_cast<const unsigned char*>(ssl_config_.next_protos.data()), | 797 for (std::vector<std::string>::const_iterator |
798 ssl_config_.next_protos.size()); | 798 j = ssl_config_.next_protos.begin(); |
799 j != ssl_config_.next_protos.end(); j++) { | |
800 if (in[i] == j->size() && | |
801 memcmp(&in[i + 1], j->data(), in[i]) == 0) { | |
802 *out = (unsigned char *)in + i + 1; | |
803 *outlen = in[i]; | |
804 status = OPENSSL_NPN_NEGOTIATED; | |
805 break; | |
joth
2011/11/02 18:57:05
where is this edit coming from? we should be using
Jing Zhao
2011/11/03 17:49:08
http://codereview.chromium.org/8156001/
This chang
joth
2011/11/03 19:45:02
ouch! that's double bad. first, linux_redux didn't
Jing Zhao
2011/11/04 08:01:43
No I didn't find a way to test this. I fixed two b
| |
806 } | |
807 } | |
808 if (status == OPENSSL_NPN_NEGOTIATED) | |
809 break; | |
810 } | |
799 | 811 |
800 npn_proto_.assign(reinterpret_cast<const char*>(*out), *outlen); | 812 npn_proto_.assign(reinterpret_cast<const char*>(*out), *outlen); |
801 switch (status) { | 813 switch (status) { |
802 case OPENSSL_NPN_UNSUPPORTED: | 814 case OPENSSL_NPN_UNSUPPORTED: |
803 npn_status_ = SSLClientSocket::kNextProtoUnsupported; | 815 npn_status_ = SSLClientSocket::kNextProtoUnsupported; |
804 break; | 816 break; |
805 case OPENSSL_NPN_NEGOTIATED: | 817 case OPENSSL_NPN_NEGOTIATED: |
806 npn_status_ = SSLClientSocket::kNextProtoNegotiated; | 818 npn_status_ = SSLClientSocket::kNextProtoNegotiated; |
807 break; | 819 break; |
808 case OPENSSL_NPN_NO_OVERLAP: | 820 case OPENSSL_NPN_NO_OVERLAP: |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1220 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_SENT, rv, | 1232 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_SENT, rv, |
1221 user_write_buf_->data()); | 1233 user_write_buf_->data()); |
1222 return rv; | 1234 return rv; |
1223 } | 1235 } |
1224 | 1236 |
1225 int err = SSL_get_error(ssl_, rv); | 1237 int err = SSL_get_error(ssl_, rv); |
1226 return MapOpenSSLError(err, err_tracer); | 1238 return MapOpenSSLError(err, err_tracer); |
1227 } | 1239 } |
1228 | 1240 |
1229 } // namespace net | 1241 } // namespace net |
OLD | NEW |