Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: net/socket/client_socket_factory.cc

Issue 4339001: Correctly handle SSL Client Authentication requests when connecting... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Addressing eroman's feedback Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/socket/client_socket_factory.h ('k') | net/socket/client_socket_pool_base_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "net/socket/client_socket_factory.h" 5 #include "net/socket/client_socket_factory.h"
6 6
7 #include "base/singleton.h" 7 #include "base/singleton.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "net/socket/client_socket_handle.h" 9 #include "net/socket/client_socket_handle.h"
10 #if defined(OS_WIN) 10 #if defined(OS_WIN)
11 #include "net/socket/ssl_client_socket_win.h" 11 #include "net/socket/ssl_client_socket_win.h"
12 #elif defined(USE_OPENSSL) 12 #elif defined(USE_OPENSSL)
13 #include "net/socket/ssl_client_socket_openssl.h" 13 #include "net/socket/ssl_client_socket_openssl.h"
14 #elif defined(USE_NSS) 14 #elif defined(USE_NSS)
15 #include "net/socket/ssl_client_socket_nss.h" 15 #include "net/socket/ssl_client_socket_nss.h"
16 #elif defined(OS_MACOSX) 16 #elif defined(OS_MACOSX)
17 #include "net/socket/ssl_client_socket_nss.h" 17 #include "net/socket/ssl_client_socket_nss.h"
18 #endif 18 #endif
19 #include "net/socket/ssl_host_info.h" 19 #include "net/socket/ssl_host_info.h"
20 #include "net/socket/tcp_client_socket.h" 20 #include "net/socket/tcp_client_socket.h"
21 21
22 namespace net { 22 namespace net {
23 23
24 class DnsRRResolver; 24 class DnsRRResolver;
25 25
26 namespace { 26 namespace {
27 27
28 SSLClientSocket* DefaultSSLClientSocketFactory( 28 SSLClientSocket* DefaultSSLClientSocketFactory(
29 ClientSocketHandle* transport_socket, 29 ClientSocketHandle* transport_socket,
30 const std::string& hostname, 30 const HostPortPair& host_and_port,
31 const SSLConfig& ssl_config, 31 const SSLConfig& ssl_config,
32 SSLHostInfo* ssl_host_info, 32 SSLHostInfo* ssl_host_info,
33 DnsRRResolver* dnsrr_resolver) { 33 DnsRRResolver* dnsrr_resolver) {
34 scoped_ptr<SSLHostInfo> shi(ssl_host_info); 34 scoped_ptr<SSLHostInfo> shi(ssl_host_info);
35 #if defined(OS_WIN) 35 #if defined(OS_WIN)
36 return new SSLClientSocketWin(transport_socket, hostname, ssl_config); 36 return new SSLClientSocketWin(transport_socket, host_and_port, ssl_config);
37 #elif defined(USE_OPENSSL) 37 #elif defined(USE_OPENSSL)
38 return new SSLClientSocketOpenSSL(transport_socket, hostname, ssl_config); 38 return new SSLClientSocketOpenSSL(transport_socket, host_and_port,
39 ssl_config);
39 #elif defined(USE_NSS) 40 #elif defined(USE_NSS)
40 return new SSLClientSocketNSS(transport_socket, hostname, ssl_config, 41 return new SSLClientSocketNSS(transport_socket, host_and_port, ssl_config,
41 shi.release(), dnsrr_resolver); 42 shi.release(), dnsrr_resolver);
42 #elif defined(OS_MACOSX) 43 #elif defined(OS_MACOSX)
43 return new SSLClientSocketNSS(transport_socket, hostname, ssl_config, 44 return new SSLClientSocketNSS(transport_socket, host_and_port, ssl_config,
44 shi.release(), dnsrr_resolver); 45 shi.release(), dnsrr_resolver);
45 #else 46 #else
46 NOTIMPLEMENTED(); 47 NOTIMPLEMENTED();
47 return NULL; 48 return NULL;
48 #endif 49 #endif
49 } 50 }
50 51
51 SSLClientSocketFactory g_ssl_factory = DefaultSSLClientSocketFactory; 52 SSLClientSocketFactory g_ssl_factory = DefaultSSLClientSocketFactory;
52 53
53 class DefaultClientSocketFactory : public ClientSocketFactory { 54 class DefaultClientSocketFactory : public ClientSocketFactory {
54 public: 55 public:
55 virtual ClientSocket* CreateTCPClientSocket( 56 virtual ClientSocket* CreateTCPClientSocket(
56 const AddressList& addresses, 57 const AddressList& addresses,
57 NetLog* net_log, 58 NetLog* net_log,
58 const NetLog::Source& source) { 59 const NetLog::Source& source) {
59 return new TCPClientSocket(addresses, net_log, source); 60 return new TCPClientSocket(addresses, net_log, source);
60 } 61 }
61 62
62 virtual SSLClientSocket* CreateSSLClientSocket( 63 virtual SSLClientSocket* CreateSSLClientSocket(
63 ClientSocketHandle* transport_socket, 64 ClientSocketHandle* transport_socket,
64 const std::string& hostname, 65 const HostPortPair& host_and_port,
65 const SSLConfig& ssl_config, 66 const SSLConfig& ssl_config,
66 SSLHostInfo* ssl_host_info, 67 SSLHostInfo* ssl_host_info,
67 DnsRRResolver* dnsrr_resolver) { 68 DnsRRResolver* dnsrr_resolver) {
68 return g_ssl_factory(transport_socket, hostname, ssl_config, ssl_host_info, 69 return g_ssl_factory(transport_socket, host_and_port, ssl_config,
69 dnsrr_resolver); 70 ssl_host_info, dnsrr_resolver);
70 } 71 }
71 }; 72 };
72 73
73 } // namespace 74 } // namespace
74 75
75 // static 76 // static
76 ClientSocketFactory* ClientSocketFactory::GetDefaultFactory() { 77 ClientSocketFactory* ClientSocketFactory::GetDefaultFactory() {
77 return Singleton<DefaultClientSocketFactory>::get(); 78 return Singleton<DefaultClientSocketFactory>::get();
78 } 79 }
79 80
80 // static 81 // static
81 void ClientSocketFactory::SetSSLClientSocketFactory( 82 void ClientSocketFactory::SetSSLClientSocketFactory(
82 SSLClientSocketFactory factory) { 83 SSLClientSocketFactory factory) {
83 g_ssl_factory = factory; 84 g_ssl_factory = factory;
84 } 85 }
85 86
86 // Deprecated function (http://crbug.com/37810) that takes a ClientSocket. 87 // Deprecated function (http://crbug.com/37810) that takes a ClientSocket.
87 SSLClientSocket* ClientSocketFactory::CreateSSLClientSocket( 88 SSLClientSocket* ClientSocketFactory::CreateSSLClientSocket(
88 ClientSocket* transport_socket, 89 ClientSocket* transport_socket,
89 const std::string& hostname, 90 const HostPortPair& host_and_port,
90 const SSLConfig& ssl_config, 91 const SSLConfig& ssl_config,
91 SSLHostInfo* ssl_host_info) { 92 SSLHostInfo* ssl_host_info) {
92 ClientSocketHandle* socket_handle = new ClientSocketHandle(); 93 ClientSocketHandle* socket_handle = new ClientSocketHandle();
93 socket_handle->set_socket(transport_socket); 94 socket_handle->set_socket(transport_socket);
94 return CreateSSLClientSocket(socket_handle, hostname, ssl_config, 95 return CreateSSLClientSocket(socket_handle, host_and_port, ssl_config,
95 ssl_host_info, NULL /* DnsRRResolver */); 96 ssl_host_info, NULL /* DnsRRResolver */);
96 } 97 }
97 98
98 } // namespace net 99 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/client_socket_factory.h ('k') | net/socket/client_socket_pool_base_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698