SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
ConfigSSL.h
Go to the documentation of this file.
1 /*
2  * SWC-DB© Copyright since 2019 Alex Kashirin <kashirin.alex@gmail.com>
3  * License details at <https://github.com/kashirin-alex/swc-db/#license>
4  */
5 
6 
7 #ifndef swcdb_core_comm_ConfigSSL_h
8 #define swcdb_core_comm_ConfigSSL_h
9 
10 
13 
14 
15 namespace SWC { namespace Comm {
16 
17 
18 class ConfigSSL final {
19  public:
20 
21  ConfigSSL(const Config::Settings& settings, bool is_client=true);
22 
23  ~ConfigSSL() noexcept { }
24 
25  void set_networks(const Config::Strings& networks, bool with_local);
26 
28  bool need_ssl(const EndPoint& remote) const noexcept {
29  return !Resolver::is_network(remote, nets_v4, nets_v6);
30  }
31 
33  bool need_ssl(const EndPoint& local,
34  const EndPoint& remote) const noexcept {
35  return local.address() != remote.address() && need_ssl(remote);
36  }
37 
39  make_connection(AppContext::Ptr& app_ctx, SocketPlain& socket) const {
40  return ConnHandlerSSL::make(app_ctx, ctx, socket);
41  }
42 
44  make_client(AppContext::Ptr& app_ctx, SocketPlain& socket) const;
45 
47  make_client(AppContext::Ptr& app_ctx, SocketPlain& socket,
48  asio::error_code& ec) const;
49 
50  private:
51 
52  void load_file(const std::string& pathbase,
53  std::string filepath, std::string& to) const;
54 
57  std::string subject_name;
58  mutable asio::ssl::context ctx;
59 
60 };
61 
62 
63 
64 }} //namespace SWC::Comm
65 
66 
67 #ifdef SWC_IMPL_SOURCE
69 #endif
70 
71 #endif // swcdb_core_comm_ConfigSSL_h
SWC::Comm::Resolver::is_network
bool is_network(const EndPoint &endpoint, const Networks_v4 &nets_v4, const Networks_v6 &nets_v6) noexcept
Definition: Resolver.cc:354
SWC::Comm::ConfigSSL::subject_name
std::string subject_name
Definition: ConfigSSL.h:57
SWC::Comm::ConnHandlerSSL::Ptr
std::shared_ptr< ConnHandlerSSL > Ptr
Definition: ConnHandler.h:299
SWC::Comm::EndPoint
asio::ip::tcp::endpoint EndPoint
Definition: Resolver.h:19
ConnHandler.h
SWC::Comm::ConfigSSL::nets_v6
Networks_v6 nets_v6
Definition: ConfigSSL.h:56
SWC::Comm::ConfigSSL::ctx
asio::ssl::context ctx
Definition: ConfigSSL.h:58
SWC::Comm::SocketPlain
asio::ip::tcp::socket SocketPlain
Definition: ConnHandler.h:25
SWC::Comm::ConfigSSL::ConfigSSL
ConfigSSL(const Config::Settings &settings, bool is_client=true)
Definition: ConfigSSL.cc:15
IoContext.h
ConfigSSL.cc
SWC::Comm::AppContext::Ptr
std::shared_ptr< AppContext > Ptr
Definition: AppContext.h:23
SWC::Comm::ConnHandlerSSL::make
static Ptr make(AppContext::Ptr &app_ctx, asio::ssl::context &ssl_ctx, SocketPlain &socket)
Definition: ConnHandler.cc:660
SWC_CAN_INLINE
#define SWC_CAN_INLINE
Definition: Compat.h:102
SWC::Comm::ConfigSSL::make_client
ConnHandlerSSL::Ptr make_client(AppContext::Ptr &app_ctx, SocketPlain &socket) const
Definition: ConfigSSL.cc:116
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::Comm::ConfigSSL::~ConfigSSL
~ConfigSSL() noexcept
Definition: ConfigSSL.h:23
SWC::Comm::ConfigSSL
Definition: ConfigSSL.h:18
SWC::Config::Settings
Definition: Settings.h:25
SWC::Comm::ConnHandlerPtr
std::shared_ptr< ConnHandler > ConnHandlerPtr
Definition: AppContext.h:17
SWC::Comm::ConfigSSL::need_ssl
SWC_CAN_INLINE bool need_ssl(const EndPoint &local, const EndPoint &remote) const noexcept
Definition: ConfigSSL.h:33
SWC::Core::Vector< std::string >
SWC::Comm::ConfigSSL::set_networks
void set_networks(const Config::Strings &networks, bool with_local)
Definition: ConfigSSL.cc:88
SWC::Common::Files::Schema::filepath
std::string filepath(cid_t cid)
Definition: Schema.h:34
SWC::Comm::ConfigSSL::need_ssl
SWC_CAN_INLINE bool need_ssl(const EndPoint &remote) const noexcept
Definition: ConfigSSL.h:28
SWC::Comm::ConfigSSL::load_file
void load_file(const std::string &pathbase, std::string filepath, std::string &to) const
Definition: ConfigSSL.cc:133
SWC::Comm::ConfigSSL::nets_v4
Networks_v4 nets_v4
Definition: ConfigSSL.h:55
SWC::Comm::ConfigSSL::make_connection
ConnHandlerSSL::Ptr make_connection(AppContext::Ptr &app_ctx, SocketPlain &socket) const
Definition: ConfigSSL.h:39