Botan c++ tls connection - Posted on Oct 19, 2024 - See https://botan.randombit.net - Logs Home - d0035
c++ tls/ssl/https, botan, boost asio beast
Botan c++ tls/ssl connection (https) with boost asio/beast.
Async Connect:
tls_stream.next_layer().async_connect(resolve_results, handler);
Handler:
[] (std::error_code ec, boost::asio::tcp::endpoint ep) { };
Async Handshake:
tls_stream.async_handshake(Botan::TLS::Connection_Side::Client, handler);
Handler:
[] (std::error_code ec) { };
Construct Botan::TLS::Stream object:
Botan::TLS::Stream tls_stream{tls_context, asio_context};
asio_context is an object of asio::io_context
tls_context is a c++ smart pointer std::shared_pointer of type Botan::TLS::Context
std::shared_ptr<Botan::TLS::Context> tls_context = std::make_shared<Botan::TLS::Context>( cred_man, rng, sess_man, policy, server_info );
cred_man - Botan Credentials Manager - std::shared_ptr smart pointer.
rng - Botan RNG, Random Number Generator - std::shared_ptr smart pointer.
sess_man - Botan TLS Session Manager - std::shared_ptr smart pointer.
policy - Botan TLS Policy - std::shared_ptr smart pointer.
server_info - Botan TLS Server Information.
std::shared_ptr<Botan::RandomNumberGenerator> rng = std::make_shared<Botan::AutoSeeded_RNG>();
std::shared_ptr<Botan::Credentials_Manager> cred_man = std::make_shared<my_credentials_manager>();
my_credentials_manager - You must implement credentials manager to provide how to get system certificate store.
class my_credentials_manager: public Botan::Credentials_Manager { ... };
std::shared_ptr<Botan::TLS::Session_Manager> sess_man = std::make_shared<Botan::TLS::Session_Manager_In_Memory>( rng );
std::shared_ptr<Botan::TLS::Policy> policy = std::make_shared<Botan::TLS::Policy>();
Botan::TLS::Server_Information server_info{};
c++ botan tls + boost asio beast (https client)
c++ std::exception:
std::cout.write(err.data(), err.size());
std::cout << std::endl;
caught:
=================================== # The c++ programming language. # # # # Join c++ Discord: yZcauUAUyC # # Deck # ===================================