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