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>
28template <
typename FunT>
29struct fn_signature_helper :
public std::false_type {};
31template <
typename R,
typename D,
typename... Args>
32struct fn_signature_helper<R (D::*)(Args...)> {
33 using type = std::function<R(Args...)>;
48 using Verify_Callback = detail::fn_signature_helper<
decltype(&Callbacks::tls_verify_cert_chain)>::type;
50 Context(std::shared_ptr<Credentials_Manager> credentials_manager,
51 std::shared_ptr<RandomNumberGenerator> rng,
52 std::shared_ptr<Session_Manager> session_manager,
53 std::shared_ptr<const Policy> policy,
54 Server_Information server_info = Server_Information()) :
55 m_credentials_manager(credentials_manager),
57 m_session_manager(session_manager),
59 m_server_info(std::move(server_info)) {}
61 virtual ~Context() =
default;
63 Context(Context&&) =
default;
64 Context(
const Context&) =
delete;
65 Context& operator=(
const Context&) =
delete;
66 Context& operator=(Context&&) =
delete;
77 void set_verify_callback(Verify_Callback callback) { m_verify_callback = std::move(callback); }
79 bool has_verify_callback()
const {
return static_cast<bool>(m_verify_callback); }
81 const Verify_Callback& get_verify_callback()
const {
return m_verify_callback; }
83 void set_server_info(Server_Information server_info) { m_server_info = std::move(server_info); }
86 template <
class S,
class C>
89 std::shared_ptr<Credentials_Manager> m_credentials_manager;
90 std::shared_ptr<RandomNumberGenerator> m_rng;
91 std::shared_ptr<Session_Manager> m_session_manager;
92 std::shared_ptr<const Policy> m_policy;
94 Server_Information m_server_info;
95 Verify_Callback m_verify_callback;