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> |
11 #include <openssl/bio.h> | 11 #include <openssl/bio.h> |
12 #include <openssl/err.h> | 12 #include <openssl/err.h> |
13 #include <openssl/ssl.h> | 13 #include <openssl/ssl.h> |
| 14 #include <string.h> |
14 | 15 |
15 #include "base/bind.h" | 16 #include "base/bind.h" |
16 #include "base/callback_helpers.h" | 17 #include "base/callback_helpers.h" |
17 #include "base/environment.h" | 18 #include "base/environment.h" |
18 #include "base/memory/singleton.h" | 19 #include "base/memory/singleton.h" |
19 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
20 #include "base/profiler/scoped_tracker.h" | 21 #include "base/profiler/scoped_tracker.h" |
21 #include "base/strings/string_piece.h" | 22 #include "base/strings/string_piece.h" |
22 #include "base/synchronization/lock.h" | 23 #include "base/synchronization/lock.h" |
23 #include "base/threading/thread_local.h" | 24 #include "base/threading/thread_local.h" |
(...skipping 1869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1893 npn_status_ = kNextProtoNegotiated; | 1894 npn_status_ = kNextProtoNegotiated; |
1894 break; | 1895 break; |
1895 } | 1896 } |
1896 } | 1897 } |
1897 if (npn_status_ == kNextProtoNegotiated) | 1898 if (npn_status_ == kNextProtoNegotiated) |
1898 break; | 1899 break; |
1899 } | 1900 } |
1900 | 1901 |
1901 // If we didn't find a protocol, we select the first one from our list. | 1902 // If we didn't find a protocol, we select the first one from our list. |
1902 if (npn_status_ == kNextProtoNoOverlap) { | 1903 if (npn_status_ == kNextProtoNoOverlap) { |
1903 const std::string proto = NextProtoToString(ssl_config_.next_protos[0]); | 1904 // NextProtoToString returns a pointer to a static string. |
1904 *out = reinterpret_cast<uint8*>(const_cast<char*>(proto.data())); | 1905 const char* proto = NextProtoToString(ssl_config_.next_protos[0]); |
1905 *outlen = proto.size(); | 1906 *out = reinterpret_cast<unsigned char*>(const_cast<char*>(proto)); |
| 1907 *outlen = strlen(proto); |
1906 } | 1908 } |
1907 | 1909 |
1908 npn_proto_.assign(reinterpret_cast<const char*>(*out), *outlen); | 1910 npn_proto_.assign(reinterpret_cast<const char*>(*out), *outlen); |
1909 DVLOG(2) << "next protocol: '" << npn_proto_ << "' status: " << npn_status_; | 1911 DVLOG(2) << "next protocol: '" << npn_proto_ << "' status: " << npn_status_; |
1910 set_negotiation_extension(kExtensionNPN); | 1912 set_negotiation_extension(kExtensionNPN); |
1911 return SSL_TLSEXT_ERR_OK; | 1913 return SSL_TLSEXT_ERR_OK; |
1912 } | 1914 } |
1913 | 1915 |
1914 long SSLClientSocketOpenSSL::MaybeReplayTransportError( | 1916 long SSLClientSocketOpenSSL::MaybeReplayTransportError( |
1915 BIO *bio, | 1917 BIO *bio, |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2013 ct::SCT_STATUS_LOG_UNKNOWN)); | 2015 ct::SCT_STATUS_LOG_UNKNOWN)); |
2014 } | 2016 } |
2015 } | 2017 } |
2016 | 2018 |
2017 scoped_refptr<X509Certificate> | 2019 scoped_refptr<X509Certificate> |
2018 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { | 2020 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { |
2019 return server_cert_; | 2021 return server_cert_; |
2020 } | 2022 } |
2021 | 2023 |
2022 } // namespace net | 2024 } // namespace net |
OLD | NEW |