QUIC - enable persisting of QUICServerInfo (server config) to disk
[chromium-blink-merge.git] / net / socket / ssl_server_socket.h
blob8b607bf80cf81e98dedc465ee0927ec51b6a430b
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 "base/memory/scoped_ptr.h"
10 #include "net/base/completion_callback.h"
11 #include "net/base/net_export.h"
12 #include "net/socket/ssl_socket.h"
13 #include "net/socket/stream_socket.h"
15 namespace crypto {
16 class RSAPrivateKey;
17 } // namespace crypto
19 namespace net {
21 struct SSLConfig;
22 class X509Certificate;
24 class SSLServerSocket : public SSLSocket {
25 public:
26 virtual ~SSLServerSocket() {}
28 // Perform the SSL server handshake, and notify the supplied callback
29 // if the process completes asynchronously. If Disconnect is called before
30 // completion then the callback will be silently, as for other StreamSocket
31 // calls.
32 virtual int Handshake(const CompletionCallback& callback) = 0;
35 // Configures the underlying SSL library for the use of SSL server sockets.
37 // Due to the requirements of the underlying libraries, this should be called
38 // early in process initialization, before any SSL socket, client or server,
39 // has been used.
41 // Note: If a process does not use SSL server sockets, this call may be
42 // omitted.
43 NET_EXPORT void EnableSSLServerSockets();
45 // Creates an SSL server socket over an already-connected transport socket.
46 // The caller must provide the server certificate and private key to use.
48 // The returned SSLServerSocket takes ownership of |socket|. Stubbed versions
49 // of CreateSSLServerSocket will delete |socket| and return NULL.
50 // It takes a reference to |certificate|.
51 // The |key| and |ssl_config| parameters are copied. |key| cannot be const
52 // because the methods used to copy its contents are non-const.
54 // The caller starts the SSL server handshake by calling Handshake on the
55 // returned socket.
56 NET_EXPORT scoped_ptr<SSLServerSocket> CreateSSLServerSocket(
57 scoped_ptr<StreamSocket> socket,
58 X509Certificate* certificate,
59 crypto::RSAPrivateKey* key,
60 const SSLConfig& ssl_config);
62 } // namespace net
64 #endif // NET_SOCKET_SSL_SERVER_SOCKET_H_