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 #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_mac.h" | |
18 #include "net/socket/ssl_client_socket_nss.h" | 17 #include "net/socket/ssl_client_socket_nss.h" |
19 #endif | 18 #endif |
20 #include "net/socket/ssl_host_info.h" | 19 #include "net/socket/ssl_host_info.h" |
21 #include "net/socket/tcp_client_socket.h" | 20 #include "net/socket/tcp_client_socket.h" |
22 | 21 |
23 namespace net { | 22 namespace net { |
24 | 23 |
25 namespace { | 24 namespace { |
26 | 25 |
27 SSLClientSocket* DefaultSSLClientSocketFactory( | 26 SSLClientSocket* DefaultSSLClientSocketFactory( |
28 ClientSocketHandle* transport_socket, | 27 ClientSocketHandle* transport_socket, |
29 const std::string& hostname, | 28 const std::string& hostname, |
30 const SSLConfig& ssl_config, | 29 const SSLConfig& ssl_config, |
31 SSLHostInfo* ssl_host_info) { | 30 SSLHostInfo* ssl_host_info) { |
32 scoped_ptr<SSLHostInfo> shi(ssl_host_info); | 31 scoped_ptr<SSLHostInfo> shi(ssl_host_info); |
33 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
34 return new SSLClientSocketWin(transport_socket, hostname, ssl_config); | 33 return new SSLClientSocketWin(transport_socket, hostname, ssl_config); |
35 #elif defined(USE_OPENSSL) | 34 #elif defined(USE_OPENSSL) |
36 return new SSLClientSocketOpenSSL(transport_socket, hostname, ssl_config); | 35 return new SSLClientSocketOpenSSL(transport_socket, hostname, ssl_config); |
37 #elif defined(USE_NSS) | 36 #elif defined(USE_NSS) |
38 return new SSLClientSocketNSS(transport_socket, hostname, ssl_config, | 37 return new SSLClientSocketNSS(transport_socket, hostname, ssl_config, |
39 shi.release()); | 38 shi.release()); |
40 #elif defined(OS_MACOSX) | 39 #elif defined(OS_MACOSX) |
41 // TODO(wtc): SSLClientSocketNSS can't do SSL client authentication using | |
42 // Mac OS X CDSA/CSSM yet (http://crbug.com/45369), so fall back on | |
43 // SSLClientSocketMac. | |
44 if (ssl_config.send_client_cert) | |
45 return new SSLClientSocketMac(transport_socket, hostname, ssl_config); | |
46 | |
47 return new SSLClientSocketNSS(transport_socket, hostname, ssl_config, | 40 return new SSLClientSocketNSS(transport_socket, hostname, ssl_config, |
48 shi.release()); | 41 shi.release()); |
49 #else | 42 #else |
50 NOTIMPLEMENTED(); | 43 NOTIMPLEMENTED(); |
51 return NULL; | 44 return NULL; |
52 #endif | 45 #endif |
53 } | 46 } |
54 | 47 |
55 SSLClientSocketFactory g_ssl_factory = DefaultSSLClientSocketFactory; | 48 SSLClientSocketFactory g_ssl_factory = DefaultSSLClientSocketFactory; |
56 | 49 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 const std::string& hostname, | 84 const std::string& hostname, |
92 const SSLConfig& ssl_config, | 85 const SSLConfig& ssl_config, |
93 SSLHostInfo* ssl_host_info) { | 86 SSLHostInfo* ssl_host_info) { |
94 ClientSocketHandle* socket_handle = new ClientSocketHandle(); | 87 ClientSocketHandle* socket_handle = new ClientSocketHandle(); |
95 socket_handle->set_socket(transport_socket); | 88 socket_handle->set_socket(transport_socket); |
96 return CreateSSLClientSocket(socket_handle, hostname, ssl_config, | 89 return CreateSSLClientSocket(socket_handle, hostname, ssl_config, |
97 ssl_host_info); | 90 ssl_host_info); |
98 } | 91 } |
99 | 92 |
100 } // namespace net | 93 } // namespace net |
OLD | NEW |