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