MeVisLab Toolbox Reference
asio::TlsAcceptorSession Class Reference

A TCP acceptor session with TLS support continuously waiting for incoming connections. More...

#include <TlsAcceptorSession.h>

Inheritance diagram for asio::TlsAcceptorSession:
asio::SocketCreationSession< TlsAcceptorSession >

Public Member Functions

unsigned short port () const
 
void start ()
 
void stop ()
 
- Public Member Functions inherited from asio::SocketCreationSession< TlsAcceptorSession >
SignalConnection observeConnectionEstablished (Slot &&slot)
 
SignalConnection observeErrorOccured (Slot &&slot)
 
SignalConnection observeAboutToBeDestroyed (Slot &&slot)
 
 ~SocketCreationSession ()
 

Friends

class SocketCreationSession< TlsAcceptorSession >
 

Additional Inherited Members

- Static Public Member Functions inherited from asio::SocketCreationSession< TlsAcceptorSession >
static std::shared_ptr< TlsAcceptorSessioncreate (Arguments &&... arguments)
 
- Protected Member Functions inherited from asio::SocketCreationSession< TlsAcceptorSession >
void emitConnectionEstablished (std::unique_ptr< Socket > socket)
 
void emitErrorOccured (const ErrorCode &ec)
 

Detailed Description

A TCP acceptor session with TLS support continuously waiting for incoming connections.

The session implements the asio::SocketCreationSession class template and signals asio::Socket interfaces for incoming encrypted connections. Synopsis:

auto context = std::make_shared<asio::Context>();
auto tls_context = std::make_shared<asio::TlsContext>(asio::TlsContext::tlsv12_server);
// configure TLS context
tls_context->set_options(asio::TlsContext::default_workarounds | asio::TlsContext::no_sslv2 | asio::TlsContext::single_dh_use);
tls_context->use_certificate_chain(boost::asio::buffer(cert.data(), cert.size()));
tls_context->use_private_key(boost::asio::buffer(pk.data(), pk.size()), asio::TlsContext::pem);
auto session = asio::TlsAcceptorSession::create(context, tls_context, "127.0.0.1", 443);
session->observeConnectionEstablished([](std::unique_ptr<asio::Socket>& socket) {
// new socket with successful TLS handshake connected!
// do something with it, encryption is added automatically
});
session->start();
context->run(); // this blocks (as usual) and normally done somewhere else.
static std::shared_ptr< TlsAcceptorSession > create(Arguments &&... arguments)

Definition at line 39 of file TlsAcceptorSession.h.

Member Function Documentation

◆ port()

unsigned short asio::TlsAcceptorSession::port ( ) const

◆ start()

void asio::TlsAcceptorSession::start ( )

◆ stop()

void asio::TlsAcceptorSession::stop ( )

Friends And Related Function Documentation

◆ SocketCreationSession< TlsAcceptorSession >

friend class SocketCreationSession< TlsAcceptorSession >
friend

Definition at line 1 of file TlsAcceptorSession.h.


The documentation for this class was generated from the following file: