9#ifndef BOTAN_ASIO_TLS_CONTEXT_H_
10#define BOTAN_ASIO_TLS_CONTEXT_H_
12#include <botan/asio_compat.h>
13#if defined(BOTAN_FOUND_COMPATIBLE_BOOST_ASIO_VERSION)
17 #include <botan/credentials_manager.h>
18 #include <botan/ocsp.h>
19 #include <botan/rng.h>
20 #include <botan/tls_callbacks.h>
21 #include <botan/tls_policy.h>
22 #include <botan/tls_server_info.h>
23 #include <botan/tls_session_manager.h>
25 #if defined(BOTAN_HAS_AUTO_SEEDING_RNG) && defined(BOTAN_HAS_CERTSTOR_SYSTEM)
26 #define BOTAN_HAS_DEFAULT_TLS_CONTEXT
29 #define BOTAN_HAS_HAS_DEFAULT_TLS_CONTEXT
35template <
typename FunT>
36struct fn_signature_helper :
public std::false_type {};
38template <
typename R,
typename D,
typename... Args>
39struct fn_signature_helper<R (D::*)(Args...)> {
40 using type = std::function<R(Args...)>;
55 using Verify_Callback = detail::fn_signature_helper<
decltype(&Callbacks::tls_verify_cert_chain)>::type;
57 #if defined(BOTAN_HAS_DEFAULT_TLS_CONTEXT)
66 Context(std::shared_ptr<Credentials_Manager> credentials_manager,
67 std::shared_ptr<RandomNumberGenerator> rng,
68 std::shared_ptr<Session_Manager> session_manager,
69 std::shared_ptr<const Policy> policy,
70 Server_Information server_info = Server_Information()) :
71 m_credentials_manager(std::move(credentials_manager)),
72 m_rng(std::move(rng)),
73 m_session_manager(std::move(session_manager)),
74 m_policy(std::move(policy)),
75 m_server_info(std::move(server_info)) {}
77 virtual ~Context() =
default;
79 Context(Context&&) =
default;
80 Context(
const Context&) =
delete;
81 Context& operator=(
const Context&) =
delete;
82 Context& operator=(Context&&) =
delete;
93 void set_verify_callback(Verify_Callback callback) { m_verify_callback = std::move(callback); }
95 bool has_verify_callback()
const {
return static_cast<bool>(m_verify_callback); }
97 const Verify_Callback& get_verify_callback()
const {
return m_verify_callback; }
99 void set_server_info(Server_Information server_info) { m_server_info = std::move(server_info); }
101 void set_app_protocols(std::vector<std::string> app_protocols = {}) {
102 m_app_protocols = std::move(app_protocols);
106 template <
class S,
class C>
108 friend class StreamCallbacks;
111 std::shared_ptr<Credentials_Manager> m_credentials_manager;
112 std::shared_ptr<RandomNumberGenerator> m_rng;
113 std::shared_ptr<Session_Manager> m_session_manager;
114 std::shared_ptr<const Policy> m_policy;
116 Server_Information m_server_info;
117 Verify_Callback m_verify_callback;
118 std::vector<std::string> m_app_protocols;
#define BOTAN_PUBLIC_API(maj, min)
#define BOTAN_FUTURE_EXPLICIT