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_HAS_DEFAULT_TLS_CONTEXT
32template <
typename FunT>
33struct fn_signature_helper :
public std::false_type {};
35template <
typename R,
typename D,
typename... Args>
36struct fn_signature_helper<R (D::*)(Args...)> {
37 using type = std::function<R(Args...)>;
52 using Verify_Callback = detail::fn_signature_helper<
decltype(&Callbacks::tls_verify_cert_chain)>::type;
54 #if defined(BOTAN_HAS_HAS_DEFAULT_TLS_CONTEXT)
60 Context(Server_Information server_info = Server_Information());
63 Context(std::shared_ptr<Credentials_Manager> credentials_manager,
64 std::shared_ptr<RandomNumberGenerator> rng,
65 std::shared_ptr<Session_Manager> session_manager,
66 std::shared_ptr<const Policy> policy,
67 Server_Information server_info = Server_Information()) :
68 m_credentials_manager(credentials_manager),
70 m_session_manager(session_manager),
72 m_server_info(std::move(server_info)) {}
74 virtual ~Context() =
default;
76 Context(Context&&) =
default;
77 Context(
const Context&) =
delete;
78 Context& operator=(
const Context&) =
delete;
79 Context& operator=(Context&&) =
delete;
90 void set_verify_callback(Verify_Callback callback) { m_verify_callback = std::move(callback); }
92 bool has_verify_callback()
const {
return static_cast<bool>(m_verify_callback); }
94 const Verify_Callback& get_verify_callback()
const {
return m_verify_callback; }
96 void set_server_info(Server_Information server_info) { m_server_info = std::move(server_info); }
99 template <
class S,
class C>
102 std::shared_ptr<Credentials_Manager> m_credentials_manager;
103 std::shared_ptr<RandomNumberGenerator> m_rng;
104 std::shared_ptr<Session_Manager> m_session_manager;
105 std::shared_ptr<const Policy> m_policy;
107 Server_Information m_server_info;
108 Verify_Callback m_verify_callback;
#define BOTAN_PUBLIC_API(maj, min)