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 1764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1775 *outlen = arraysize(kDefaultSupportedNPNProtocol) - 1; | 1775 *outlen = arraysize(kDefaultSupportedNPNProtocol) - 1; |
1776 npn_status_ = kNextProtoUnsupported; | 1776 npn_status_ = kNextProtoUnsupported; |
1777 return SSL_TLSEXT_ERR_OK; | 1777 return SSL_TLSEXT_ERR_OK; |
1778 } | 1778 } |
1779 | 1779 |
1780 // Assume there's no overlap between our protocols and the server's list. | 1780 // Assume there's no overlap between our protocols and the server's list. |
1781 npn_status_ = kNextProtoNoOverlap; | 1781 npn_status_ = kNextProtoNoOverlap; |
1782 | 1782 |
1783 // For each protocol in server preference order, see if we support it. | 1783 // For each protocol in server preference order, see if we support it. |
1784 for (unsigned int i = 0; i < inlen; i += in[i] + 1) { | 1784 for (unsigned int i = 0; i < inlen; i += in[i] + 1) { |
1785 for (std::vector<std::string>::const_iterator | 1785 for (NextProtoVector::const_iterator j = ssl_config_.next_protos.begin(); |
1786 j = ssl_config_.next_protos.begin(); | |
1787 j != ssl_config_.next_protos.end(); ++j) { | 1786 j != ssl_config_.next_protos.end(); ++j) { |
Ryan Hamilton
2014/12/10 20:09:00
for (NextProto next_proto : ssl_config_.next_proto
Bence
2014/12/10 22:01:23
Done.
| |
1788 if (in[i] == j->size() && | 1787 const std::string proto = NextProtoToString(*j); |
1789 memcmp(&in[i + 1], j->data(), in[i]) == 0) { | 1788 if (in[i] == proto.size() && |
1789 memcmp(&in[i + 1], proto.data(), in[i]) == 0) { | |
1790 // We found a match. | 1790 // We found a match. |
1791 *out = const_cast<unsigned char*>(in) + i + 1; | 1791 *out = const_cast<unsigned char*>(in) + i + 1; |
1792 *outlen = in[i]; | 1792 *outlen = in[i]; |
1793 npn_status_ = kNextProtoNegotiated; | 1793 npn_status_ = kNextProtoNegotiated; |
1794 break; | 1794 break; |
1795 } | 1795 } |
1796 } | 1796 } |
1797 if (npn_status_ == kNextProtoNegotiated) | 1797 if (npn_status_ == kNextProtoNegotiated) |
1798 break; | 1798 break; |
1799 } | 1799 } |
1800 | 1800 |
1801 // If we didn't find a protocol, we select the first one from our list. | 1801 // If we didn't find a protocol, we select the first one from our list. |
1802 if (npn_status_ == kNextProtoNoOverlap) { | 1802 if (npn_status_ == kNextProtoNoOverlap) { |
1803 *out = reinterpret_cast<uint8*>(const_cast<char*>( | 1803 const std::string proto = NextProtoToString(ssl_config_.next_protos[0]); |
1804 ssl_config_.next_protos[0].data())); | 1804 *out = reinterpret_cast<uint8*>(const_cast<char*>(proto.data())); |
1805 *outlen = ssl_config_.next_protos[0].size(); | 1805 *outlen = proto.size(); |
1806 } | 1806 } |
1807 | 1807 |
1808 npn_proto_.assign(reinterpret_cast<const char*>(*out), *outlen); | 1808 npn_proto_.assign(reinterpret_cast<const char*>(*out), *outlen); |
1809 DVLOG(2) << "next protocol: '" << npn_proto_ << "' status: " << npn_status_; | 1809 DVLOG(2) << "next protocol: '" << npn_proto_ << "' status: " << npn_status_; |
1810 set_negotiation_extension(kExtensionNPN); | 1810 set_negotiation_extension(kExtensionNPN); |
1811 return SSL_TLSEXT_ERR_OK; | 1811 return SSL_TLSEXT_ERR_OK; |
1812 } | 1812 } |
1813 | 1813 |
1814 long SSLClientSocketOpenSSL::MaybeReplayTransportError( | 1814 long SSLClientSocketOpenSSL::MaybeReplayTransportError( |
1815 BIO *bio, | 1815 BIO *bio, |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1903 ct::SCT_STATUS_LOG_UNKNOWN)); | 1903 ct::SCT_STATUS_LOG_UNKNOWN)); |
1904 } | 1904 } |
1905 } | 1905 } |
1906 | 1906 |
1907 scoped_refptr<X509Certificate> | 1907 scoped_refptr<X509Certificate> |
1908 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { | 1908 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { |
1909 return server_cert_; | 1909 return server_cert_; |
1910 } | 1910 } |
1911 | 1911 |
1912 } // namespace net | 1912 } // namespace net |
OLD | NEW |