join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
join::BasicTlsAcceptor< Protocol > Class Template Reference

basic TLS acceptor class. More...

#include <acceptor.hpp>

Inheritance diagram for join::BasicTlsAcceptor< Protocol >:
Collaboration diagram for join::BasicTlsAcceptor< Protocol >:

Public Types

using Endpoint = typename Protocol::Endpoint
 
using Socket = typename Protocol::Socket
 
using Stream = typename Protocol::Stream
 
- Public Types inherited from join::BasicStreamAcceptor< Protocol >
using Endpoint = typename Protocol::Endpoint
 
using Socket = typename Protocol::Socket
 
using Stream = typename Protocol::Stream
 

Public Member Functions

 BasicTlsAcceptor ()
 create the acceptor instance.
 
 BasicTlsAcceptor (const BasicTlsAcceptor &other)=delete
 copy constructor.
 
BasicTlsAcceptoroperator= (const BasicTlsAcceptor &other)=delete
 copy assignment operator.
 
 BasicTlsAcceptor (BasicTlsAcceptor &&other)
 move constructor.
 
BasicTlsAcceptoroperator= (BasicTlsAcceptor &&other)
 move assignment operator.
 
virtual Socket accept () const override
 accept new connection and fill in the client object with connection parameters.
 
virtual Socket acceptEncrypted () const
 accept new connection and fill in the client object with connection parameters.
 
virtual Stream acceptStreamEncrypted () const
 accept new connection and fill in the client object with connection parameters.
 
int setCertificate (const std::string &cert, const std::string &key="")
 set the certificate and the private key.
 
int setCaCertificate (const std::string &caFile)
 Set the location of the trusted CA certificate.
 
void setVerify (bool verify, int depth=-1)
 Enable/Disable the verification of the peer certificate.
 
int setCipher (const std::string &cipher)
 set the cipher list (TLSv1.2 and below).
 
int setCipher_1_3 (const std::string &cipher)
 set the cipher list (TLSv1.3).
 
- Public Member Functions inherited from join::BasicStreamAcceptor< Protocol >
 BasicStreamAcceptor ()=default
 create the acceptor instance.
 
 BasicStreamAcceptor (const BasicStreamAcceptor &other)=delete
 copy constructor.
 
BasicStreamAcceptoroperator= (const BasicStreamAcceptor &other)=delete
 copy assignment operator.
 
 BasicStreamAcceptor (BasicStreamAcceptor &&other)
 move constructor.
 
BasicStreamAcceptoroperator= (BasicStreamAcceptor &&other)
 move assignment operator.
 
virtual ~BasicStreamAcceptor ()
 destroy instance.
 
virtual int create (const Endpoint &endpoint) noexcept
 create acceptor
 
virtual void close () noexcept
 close acceptor.
 
virtual Stream acceptStream () const
 accept new connection and fill in the client object with connection parameters.
 
Endpoint localEndpoint () const
 determine the local endpoint associated with this socket.
 
bool opened () const noexcept
 check if the socket is opened.
 
int family () const noexcept
 get address family.
 
int type () const noexcept
 get the protocol communication semantic.
 
int protocol () const noexcept
 get acceptor protocol.
 
int handle () const noexcept override
 get socket native handle.
 
- Public Member Functions inherited from join::EventHandler
 EventHandler ()=default
 create instance.
 
virtual ~EventHandler ()=default
 destroy instance.
 

Static Protected Member Functions

static DH * getDh2236 ()
 generate openssl Diffie-Hellman parameters.
 

Protected Attributes

join::SslCtxPtr _tlsContext
 SSL/TLS context.
 
int _sessionId = 0
 SSL session id.
 
- Protected Attributes inherited from join::BasicStreamAcceptor< Protocol >
int _handle = -1
 socket handle.
 
Protocol _protocol
 protocol.
 

Additional Inherited Members

- Protected Member Functions inherited from join::EventHandler
virtual void onReceive ()
 method called when data are ready to be read on handle.
 
virtual void onClose ()
 method called when handle is closed.
 
virtual void onError ()
 method called when an error occured on handle.
 

Detailed Description

template<class Protocol>
class join::BasicTlsAcceptor< Protocol >

basic TLS acceptor class.

Member Typedef Documentation

◆ Endpoint

template<class Protocol >
using join::BasicTlsAcceptor< Protocol >::Endpoint = typename Protocol::Endpoint

◆ Socket

template<class Protocol >
using join::BasicTlsAcceptor< Protocol >::Socket = typename Protocol::Socket

◆ Stream

template<class Protocol >
using join::BasicTlsAcceptor< Protocol >::Stream = typename Protocol::Stream

Constructor & Destructor Documentation

◆ BasicTlsAcceptor() [1/3]

template<class Protocol >
join::BasicTlsAcceptor< Protocol >::BasicTlsAcceptor ( )
inline

create the acceptor instance.

◆ BasicTlsAcceptor() [2/3]

template<class Protocol >
join::BasicTlsAcceptor< Protocol >::BasicTlsAcceptor ( const BasicTlsAcceptor< Protocol > & other)
delete

copy constructor.

Parameters
otherother object to copy.

◆ BasicTlsAcceptor() [3/3]

template<class Protocol >
join::BasicTlsAcceptor< Protocol >::BasicTlsAcceptor ( BasicTlsAcceptor< Protocol > && other)
inline

move constructor.

Parameters
otherother object to move.

Member Function Documentation

◆ accept()

template<class Protocol >
virtual Socket join::BasicTlsAcceptor< Protocol >::accept ( ) const
inlineoverridevirtual

accept new connection and fill in the client object with connection parameters.

Returns
the accepted client socket object.

Reimplemented from join::BasicStreamAcceptor< Protocol >.

◆ acceptEncrypted()

template<class Protocol >
virtual Socket join::BasicTlsAcceptor< Protocol >::acceptEncrypted ( ) const
inlinevirtual

accept new connection and fill in the client object with connection parameters.

Returns
the accepted client socket object.

◆ acceptStreamEncrypted()

template<class Protocol >
virtual Stream join::BasicTlsAcceptor< Protocol >::acceptStreamEncrypted ( ) const
inlinevirtual

accept new connection and fill in the client object with connection parameters.

Returns
The client stream object on success, nullptr on failure.

◆ getDh2236()

template<class Protocol >
static DH * join::BasicTlsAcceptor< Protocol >::getDh2236 ( )
inlinestaticprotected

generate openssl Diffie-Hellman parameters.

Note
random Diffie-Hellman parameters generated using the command "openssl dhparam -C 2236".
Returns
Diffie-Hellman parameters.

◆ operator=() [1/2]

template<class Protocol >
BasicTlsAcceptor & join::BasicTlsAcceptor< Protocol >::operator= ( BasicTlsAcceptor< Protocol > && other)
inline

move assignment operator.

Parameters
otherother object to assign.
Returns
assigned object.

◆ operator=() [2/2]

template<class Protocol >
BasicTlsAcceptor & join::BasicTlsAcceptor< Protocol >::operator= ( const BasicTlsAcceptor< Protocol > & other)
delete

copy assignment operator.

Parameters
otherother object to assign.
Returns
assigned object.

◆ setCaCertificate()

template<class Protocol >
int join::BasicTlsAcceptor< Protocol >::setCaCertificate ( const std::string & caFile)
inline

Set the location of the trusted CA certificate.

Parameters
caFilepath of the trusted CA certificate file.
Returns
0 on success, -1 on failure.

◆ setCertificate()

template<class Protocol >
int join::BasicTlsAcceptor< Protocol >::setCertificate ( const std::string & cert,
const std::string & key = "" )
inline

set the certificate and the private key.

Parameters
certcertificate path.
keyprivate key path.
Returns
0 on success, -1 on failure.

◆ setCipher()

template<class Protocol >
int join::BasicTlsAcceptor< Protocol >::setCipher ( const std::string & cipher)
inline

set the cipher list (TLSv1.2 and below).

Parameters
cipherthe cipher list.
Returns
0 on success, -1 on failure.

◆ setCipher_1_3()

template<class Protocol >
int join::BasicTlsAcceptor< Protocol >::setCipher_1_3 ( const std::string & cipher)
inline

set the cipher list (TLSv1.3).

Parameters
cipherthe cipher list.
Returns
0 on success, -1 on failure.

◆ setVerify()

template<class Protocol >
void join::BasicTlsAcceptor< Protocol >::setVerify ( bool verify,
int depth = -1 )
inline

Enable/Disable the verification of the peer certificate.

Parameters
verifyEnable peer verification if set to true, false otherwise.
depthThe maximum certificate verification depth (default: no limit).

Member Data Documentation

◆ _sessionId

template<class Protocol >
int join::BasicTlsAcceptor< Protocol >::_sessionId = 0
protected

SSL session id.

◆ _tlsContext

template<class Protocol >
join::SslCtxPtr join::BasicTlsAcceptor< Protocol >::_tlsContext
protected

SSL/TLS context.


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