From c742bc3f57cb00d84e2df034f757d4a39e3ade7e Mon Sep 17 00:00:00 2001 From: Claudius Holeksa Date: Sat, 29 Apr 2023 19:06:53 +0200 Subject: Added io tls with gnutls --- forstio/io-tls/tls.h | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 forstio/io-tls/tls.h (limited to 'forstio/io-tls/tls.h') diff --git a/forstio/io-tls/tls.h b/forstio/io-tls/tls.h new file mode 100644 index 0000000..8a31c1d --- /dev/null +++ b/forstio/io-tls/tls.h @@ -0,0 +1,70 @@ +#pragma once + +#include +#include + +#include +#include + +namespace saw { +class Tls; + +class TlsServer final : public server { +private: + own internal; + +public: + TlsServer(own srv); + + conveyor> accept() override; +}; + +class TlsNetwork final : public network { +private: + Tls& tls; + network &internal; +public: + TlsNetwork(Tls& tls_, network &network_); + + conveyor> resolve_address(const std::string &addr, uint16_t port = 0) override; + + own listen(network_address& address) override; + + conveyor> connect(network_address& address) override; + + own datagram(network_address& address) override; +}; + +/** +* Tls context class. +* Provides tls network class which ensures the usage of tls encrypted connections +*/ +class Tls { +private: + class Impl; + own impl; +public: + Tls(); + ~Tls(); + + struct Version { + struct Tls_1_0{}; + struct Tls_1_1{}; + struct Tls_1_2{}; + }; + + struct Options { + public: + Version version; + }; + + network& tlsNetwork(); + + Impl &getImpl(); +private: + Options options; +}; + +std::optional> setupTlsNetwork(network &network); + +} // namespace saw -- cgit v1.2.3