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 #ifndef NET_SOCKET_SSL_SERVER_SOCKET_H_ | 5 #ifndef NET_SOCKET_SSL_SERVER_SOCKET_H_ |
6 #define NET_SOCKET_SSL_SERVER_SOCKET_H_ | 6 #define NET_SOCKET_SSL_SERVER_SOCKET_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "net/base/completion_callback.h" | 9 #include "net/base/completion_callback.h" |
10 #include "net/base/net_api.h" | 10 #include "net/base/net_api.h" |
11 #include "net/socket/socket.h" | 11 #include "net/socket/stream_socket.h" |
12 | 12 |
13 namespace crypto { | 13 namespace crypto { |
14 class RSAPrivateKey; | 14 class RSAPrivateKey; |
15 } // namespace base | 15 } // namespace base |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 | 18 |
19 class IOBuffer; | 19 class IOBuffer; |
20 struct SSLConfig; | 20 struct SSLConfig; |
21 class X509Certificate; | 21 class X509Certificate; |
22 | 22 |
23 // SSLServerSocket takes an already connected socket and performs SSL on top of | 23 typedef StreamSocket SSLServerSocket; |
24 // it. | 24 |
| 25 // Creates an SSL server-side StreamSocket over an already-connected transport |
| 26 // StreamSocket. The caller must provide the server certificate and private |
| 27 // key to use. |
25 // | 28 // |
26 // This class is designed to work in a peer-to-peer connection and is not | 29 // The returned SSLServerSocket takes ownership of |socket|. Stubbed versions |
27 // intended to be used as a standalone SSL server. | 30 // of CreateSSLServerSocket will delete |socket| and return NULL. |
28 class SSLServerSocket : public Socket { | 31 // It takes a reference to |certificate|. |
29 public: | 32 // The |key| and |ssl_config| parameters are copied. |key| cannot be const |
30 virtual ~SSLServerSocket() {} | 33 // because the methods used to copy its contents are non-const. |
31 | |
32 // Performs an SSL server handshake on the existing socket. The given socket | |
33 // must have already been connected. | |
34 // | |
35 // Accept either returns ERR_IO_PENDING, in which case the given callback | |
36 // will be called in the future with the real result, or it completes | |
37 // synchronously, returning the result immediately. | |
38 virtual int Accept(CompletionCallback* callback) = 0; | |
39 }; | |
40 | |
41 // Creates an SSL server socket using an already connected socket. A certificate | |
42 // and private key needs to be provided. | |
43 // | 34 // |
44 // This created server socket will take ownership of |socket|. However |key| | 35 // The caller starts the SSL server handshake by calling Connect on the |
45 // is copied. | 36 // returned socket. |
46 // TODO(hclam): Defines ServerSocketFactory to create SSLServerSocket. This will | |
47 // make mocking easier. | |
48 NET_API SSLServerSocket* CreateSSLServerSocket( | 37 NET_API SSLServerSocket* CreateSSLServerSocket( |
49 Socket* socket, X509Certificate* certificate, crypto::RSAPrivateKey* key, | 38 StreamSocket* socket, |
| 39 X509Certificate* certificate, |
| 40 crypto::RSAPrivateKey* key, |
50 const SSLConfig& ssl_config); | 41 const SSLConfig& ssl_config); |
51 | 42 |
52 } // namespace net | 43 } // namespace net |
53 | 44 |
54 #endif // NET_SOCKET_SSL_SERVER_SOCKET_NSS_H_ | 45 #endif // NET_SOCKET_SSL_SERVER_SOCKET_NSS_H_ |
OLD | NEW |