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
3 // found in the LICENSE file.
5 #ifndef NET_SOCKET_SSL_SERVER_SOCKET_H_
6 #define NET_SOCKET_SSL_SERVER_SOCKET_H_
8 #include "base/basictypes.h"
9 #include "net/base/completion_callback.h"
10 #include "net/base/net_export.h"
11 #include "net/socket/ssl_socket.h"
12 #include "net/socket/stream_socket.h"
21 class X509Certificate
;
23 class SSLServerSocket
: public SSLSocket
{
25 virtual ~SSLServerSocket() {}
27 // Perform the SSL server handshake, and notify the supplied callback
28 // if the process completes asynchronously. If Disconnect is called before
29 // completion then the callback will be silently, as for other StreamSocket
31 virtual int Handshake(const CompletionCallback
& callback
) = 0;
34 // Configures the underlying SSL library for the use of SSL server sockets.
36 // Due to the requirements of the underlying libraries, this should be called
37 // early in process initialization, before any SSL socket, client or server,
40 // Note: If a process does not use SSL server sockets, this call may be
42 NET_EXPORT
void EnableSSLServerSockets();
44 // Creates an SSL server socket over an already-connected transport socket.
45 // The caller must provide the server certificate and private key to use.
47 // The returned SSLServerSocket takes ownership of |socket|. Stubbed versions
48 // of CreateSSLServerSocket will delete |socket| and return NULL.
49 // It takes a reference to |certificate|.
50 // The |key| and |ssl_config| parameters are copied. |key| cannot be const
51 // because the methods used to copy its contents are non-const.
53 // The caller starts the SSL server handshake by calling Handshake on the
55 NET_EXPORT SSLServerSocket
* CreateSSLServerSocket(
57 X509Certificate
* certificate
,
58 crypto::RSAPrivateKey
* key
,
59 const SSLConfig
& ssl_config
);
63 #endif // NET_SOCKET_SSL_SERVER_SOCKET_H_