Go to the documentation of this file.
9 #ifndef EAGINE_MESSAGE_BUS_CONTEXT_HPP
10 #define EAGINE_MESSAGE_BUS_CONTEXT_HPP
12 #include "../flat_map.hpp"
13 #include "../main_ctx_object.hpp"
14 #include "../memory/buffer.hpp"
15 #include "../message_id.hpp"
17 #include "../ssl_api.hpp"
27 struct context_remote_node {
28 std::array<byte, 256> nonce{};
29 memory::buffer cert_pem;
30 sslp::owned_x509 cert{};
31 sslp::owned_pkey pubkey{};
32 bool verified_key{
false};
56 auto ssl() noexcept -> sslp::ssl_api& {
103 return view(_own_cert_pem);
112 return view(_ca_cert_pem);
139 -> decltype(
ssl().message_digest_sha256());
141 auto message_digest_sign_init(
142 sslp::message_digest mdc,
143 sslp::message_digest_type mdt) noexcept
144 -> decltype(
ssl().message_digest_sign_init.fake());
146 auto message_digest_verify_init(
147 sslp::message_digest mdc,
148 sslp::message_digest_type mdt,
150 -> decltype(
ssl().message_digest_verify_init.fake());
155 auto verify_remote_signature(
166 std::mt19937_64 _rand_engine{std::random_device{}()};
167 flat_map<message_id, message_sequence_t> _msg_id_seq{};
169 memory::buffer _scratch_space{};
170 memory::buffer _own_cert_pem{};
171 memory::buffer _ca_cert_pem{};
173 sslp::ssl_api _ssl{};
174 sslp::owned_engine _ssl_engine{};
175 sslp::owned_x509_store _ssl_store{};
176 sslp::owned_x509 _own_cert{};
177 sslp::owned_x509 _ca_cert{};
178 sslp::owned_pkey _own_pkey{};
180 std::map<identifier_t, context_remote_node> _remotes{};
185 #if !EAGINE_LINK_LIBRARY || defined(EAGINE_IMPLEMENTING_LIBRARY)
186 #include <eagine/message_bus/context.inl>
189 #endif // EAGINE_MESSAGE_BUS_CONTEXT_HPP
Helper class used to initialize main context objects.
Definition: main_ctx_object.hpp:45
Base class for main context objects.
Definition: main_ctx_object.hpp:71
auto add_ca_certificate_pem(memory::const_block) -> bool
Sets a CA certificate encoded in PEM format.
auto next_sequence_no(message_id) noexcept -> message_sequence_t
Returns the next sequence number value for the specified message type.
basic_block< true > const_block
Alias for const byte memory span.
Definition: block.hpp:32
Class for manipulating and testing a group of enumeration-based bits.
Definition: bitfield.hpp:19
auto get_router_certificate_pem() const noexcept -> memory::const_block
Gets the router certificate encoded in PEM format.
Definition: context.hpp:128
static constexpr auto view(T *addr, S size) noexcept -> const_span< T >
Creates a view starting at the specified pointer and specified length.
Definition: span.hpp:458
Class holding common message bus utility objects.
Definition: context.hpp:37
Non-owning wrapper for C-API opaque handle types.
Definition: handle.hpp:26
auto default_message_digest() noexcept -> decltype(ssl().message_digest_sha256())
Returns the default message digest type.
std::uint32_t message_sequence_t
Alias for message sequence number type.
Definition: types.hpp:22
Non-owning view of a contiguous range of memory with ValueType elements.
Definition: flatten_fwd.hpp:16
auto operator=(context &&)=delete
Not move assignable.
auto verify_certificate(sslp::x509 cert) -> bool
Verifies the specified x509 certificate.
auto add_remote_certificate_pem(identifier_t node_id, memory::const_block) -> bool
Sets remote bus node certificate encoded in PEM format.
Message bus code is placed in this namespace.
Definition: eagine.hpp:58
auto add_own_certificate_pem(memory::const_block) -> bool
Sets this bus node certificate encoded in PEM format.
auto get_remote_certificate_pem(identifier_t) const noexcept -> memory::const_block
Gets remote bus node certificate encoded in PEM format.
auto ssl() noexcept -> sslp::ssl_api &
Returns a reference to the SSL API wrapper.
Definition: context.hpp:56
auto get_own_certificate_pem() const noexcept -> memory::const_block
Gets this bus node certificate encoded in PEM format.
Definition: context.hpp:102
std::uint64_t identifier_t
The underlying integer type for eagine::identifier.
Definition: identifier_t.hpp:19
Class storing two identifier values representing class/method pair.
Definition: message_id.hpp:25
auto get_ca_certificate_pem() const noexcept -> memory::const_block
Gets the CA certificate encoded in PEM format.
Definition: context.hpp:111
auto verified_remote_key(identifier_t) const noexcept -> bool
Indicates if the private key of a remote node was verified.
auto add_router_certificate_pem(memory::const_block blk) -> bool
Sets the router certificate encoded in PEM format.
Definition: context.hpp:93
auto get_own_signature(memory::const_block) -> memory::const_block
Signs the specified memory block and returns the signature.