1 // Copyright 2014 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_IMPL_H_
6 #define NET_SOCKET_SSL_SERVER_SOCKET_IMPL_H_
7 
8 #include <stdint.h>
9 
10 #include <memory>
11 
12 #include "base/macros.h"
13 #include "net/base/io_buffer.h"
14 #include "net/socket/ssl_server_socket.h"
15 #include "net/ssl/ssl_server_config.h"
16 #include "third_party/boringssl/src/include/openssl/base.h"
17 
18 namespace net {
19 
20 class SSLServerContextImpl : public SSLServerContext {
21  public:
22   SSLServerContextImpl(X509Certificate* certificate,
23                        EVP_PKEY* pkey,
24                        const SSLServerConfig& ssl_server_config);
25   SSLServerContextImpl(X509Certificate* certificate,
26                        scoped_refptr<SSLPrivateKey> key,
27                        const SSLServerConfig& ssl_server_config);
28   ~SSLServerContextImpl() override;
29 
30   std::unique_ptr<SSLServerSocket> CreateSSLServerSocket(
31       std::unique_ptr<StreamSocket> socket) override;
32 
33  private:
34   class SocketImpl;
35 
36   void Init();
37 
38   bssl::UniquePtr<SSL_CTX> ssl_ctx_;
39 
40   // Options for the SSL socket.
41   SSLServerConfig ssl_server_config_;
42 
43   // Certificate for the server.
44   scoped_refptr<X509Certificate> cert_;
45 
46   // Private key used by the server.
47   // Only one representation should be set at any time.
48   bssl::UniquePtr<EVP_PKEY> pkey_;
49   const scoped_refptr<SSLPrivateKey> private_key_;
50 };
51 
52 }  // namespace net
53 
54 #endif  // NET_SOCKET_SSL_SERVER_SOCKET_IMPL_H_
55