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

TLS stream class. More...

#include <socketstream.hpp>

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

Public Types

using SocketStreambuf = BasicSocketStreambuf <Protocol>
 
using Endpoint = typename Protocol::Endpoint
 
using Socket = typename Protocol::Socket
 
- Public Types inherited from join::BasicSocketStream< Protocol >
using SocketStreambuf = BasicSocketStreambuf <Protocol>
 
using Endpoint = typename Protocol::Endpoint
 
using Socket = typename Protocol::Socket
 

Public Member Functions

 BasicTlsStream ()
 default constructor.
 
 BasicTlsStream (const BasicTlsStream &other)=delete
 copy constructor.
 
BasicTlsStreamoperator= (const BasicTlsStream &other)=delete
 copy assignment operator.
 
 BasicTlsStream (BasicTlsStream &&other)
 move constructor.
 
BasicTlsStreamoperator= (BasicTlsStream &&other)
 move assignment operator.
 
virtual ~BasicTlsStream ()=default
 destroy the TLS stream instance.
 
void startEncryption ()
 start socket encryption (perform TLS handshake).
 
void connectEncrypted (const Endpoint &endpoint)
 make an encrypted connection to the given endpoint.
 
int setCertificate (const std::string &cert, const std::string &key="")
 set the certificate and the private key.
 
int setCaPath (const std::string &caPath)
 set the location of the trusted CA certificates.
 
int setCaFile (const std::string &caFile)
 set the location of the trusted CA certificate file.
 
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::BasicSocketStream< Protocol >
 BasicSocketStream ()
 default constructor.
 
 BasicSocketStream (const BasicSocketStream &other)=delete
 copy constructor.
 
BasicSocketStreamoperator= (const BasicSocketStream &other)=delete
 copy assignment operator.
 
 BasicSocketStream (BasicSocketStream &&other)
 move constructor.
 
BasicSocketStreamoperator= (BasicSocketStream &&other)
 move assignment operator.
 
virtual ~BasicSocketStream ()=default
 destroy the socket stream instance.
 
virtual void bind (const Endpoint &endpoint)
 assigns the specified endpoint to the socket.
 
virtual void connect (const Endpoint &endpoint)
 make a connection to the given endpoint.
 
virtual void disconnect ()
 shutdown the connection.
 
virtual void close ()
 close the connection.
 
Endpoint localEndpoint ()
 determine the local endpoint associated with this socket.
 
const EndpointremoteEndpoint ()
 determine the remote endpoint associated with this socket.
 
bool opened ()
 check if the socket is opened.
 
bool connected ()
 check if the socket is connected.
 
bool encrypted ()
 check if the socket is secure.
 
void timeout (int ms)
 set the socket timeout.
 
int timeout () const
 get the current timeout in milliseconds.
 
Socketsocket ()
 get the nested socket.
 

Additional Inherited Members

- Protected Attributes inherited from join::BasicSocketStream< Protocol >
SocketStreambuf _sockbuf
 associated stream buffer.
 

Detailed Description

template<class Protocol>
class join::BasicTlsStream< Protocol >

TLS stream class.

Member Typedef Documentation

◆ Endpoint

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

◆ Socket

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

◆ SocketStreambuf

template<class Protocol >
using join::BasicTlsStream< Protocol >::SocketStreambuf = BasicSocketStreambuf <Protocol>

Constructor & Destructor Documentation

◆ BasicTlsStream() [1/3]

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

default constructor.

◆ BasicTlsStream() [2/3]

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

copy constructor.

Parameters
otherother object to copy.

◆ BasicTlsStream() [3/3]

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

move constructor.

Parameters
otherother object to move.

◆ ~BasicTlsStream()

template<class Protocol >
virtual join::BasicTlsStream< Protocol >::~BasicTlsStream ( )
virtualdefault

destroy the TLS stream instance.

Member Function Documentation

◆ connectEncrypted()

template<class Protocol >
void join::BasicTlsStream< Protocol >::connectEncrypted ( const Endpoint & endpoint)
inline

make an encrypted connection to the given endpoint.

Parameters
endpointendpoint to connect to.
Exceptions
std::ios_base::failure.

◆ operator=() [1/2]

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

move assignment operator.

Parameters
otherother object to assign.
Returns
current object.

◆ operator=() [2/2]

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

copy assignment operator.

Parameters
otherother object to assign.
Returns
current object.

◆ setCaFile()

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

set the location of the trusted CA certificate file.

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

◆ setCaPath()

template<class Protocol >
int join::BasicTlsStream< Protocol >::setCaPath ( const std::string & caPath)
inline

set the location of the trusted CA certificates.

Parameters
caPathpath of the trusted CA certificates.
Returns
0 on success, -1 on failure.

◆ setCertificate()

template<class Protocol >
int join::BasicTlsStream< 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::BasicTlsStream< 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::BasicTlsStream< 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::BasicTlsStream< 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).

◆ startEncryption()

template<class Protocol >
void join::BasicTlsStream< Protocol >::startEncryption ( )
inline

start socket encryption (perform TLS handshake).

Returns
0 on success, -1 on failure.

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