TSDuck v3.45-4766
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches

Context of a TLS connection. More...

#include <tsTLSContext.h>

Inheritance diagram for ts::TLSContext:
Collaboration diagram for ts::TLSContext:

Public Member Functions

 TLSContext (Report *report)
 Constructor.
 
 TLSContext (ReporterBase *delegate)
 Constructor.
 
virtual ~TLSContext () override
 Destructor.
 
bool eof () const
 Check if the input TLS stream is terminated (peer shutdown).
 
size_t getDataSizeToSend () const
 Get the size in bytes of TLS protocol data which are ready to send.
 
bool getDataToSend (ByteBlock &tls_data)
 Get TLS protocol data to send.
 
bool initClient (const TLSConnectionBase &params)
 Initialize the client side of a connection.
 
bool initServer (void *cert)
 Initialize the server side of a connection.
 
bool initShutdown (bool silent)
 Generate a shutdown message to send to the peer.
 
bool muteReport (bool mute)
 Temporarily mute the associated report.
 
bool needReceive () const
 Check if more TLS protocol data must be received in order to continue.
 
bool needSend () const
 Check if some TLS protocol data must be sent.
 
bool provideClearData (const void *data, size_t size, size_t &ret_size)
 Send clear user data over the TLS connection.
 
bool provideReceivedData (const void *data, size_t size, size_t &ret_size, ByteBlock &clear_data)
 Provide received TLS protocol data, collect clear data.
 
virtual Reportreport () const override
 Access the Report which is associated with this object.
 
void reset ()
 Clear the context, free all resources.
 
bool serverSide () const
 Check if this is the server-side of the TLS connection.
 
ReportsetReport (Report *report)
 Associate this object with another Report to log errors.
 
ReporterBasesetReport (ReporterBase *delegate)
 Associate this object with another ReporterBase to log errors.
 
bool shutdowning () const
 Check if a TLS shutdown was generated.
 

Static Public Member Functions

static UString GetLibraryVersion ()
 Get the version of the underlying SSL/TLS library.
 
static int SilentLevel (bool silent, int default_severity=Severity::Error)
 Compute a log severity level from a "silent" parameter.
 

Detailed Description

Context of a TLS connection.

This is state machine working on pure data, non-blocking, without network access.

Constructor & Destructor Documentation

◆ TLSContext() [1/2]

ts::TLSContext::TLSContext ( Report report)
explicit

Constructor.

Parameters
[in]reportWhere to report errors. The report object must remain valid as long as this object exists or setReport() is used with another Report object. If report is null, log messages are discarded.

◆ TLSContext() [2/2]

ts::TLSContext::TLSContext ( ReporterBase delegate)
explicit

Constructor.

Parameters
[in]delegateUse the report of another ReporterBase. If delegate is null, log messages are discarded.

Member Function Documentation

◆ initClient()

bool ts::TLSContext::initClient ( const TLSConnectionBase params)

Initialize the client side of a connection.

Parameters
[in]paramsTLS connection parameters.
Returns
True on success, false on error.

◆ initServer()

bool ts::TLSContext::initServer ( void *  cert)

Initialize the server side of a connection.

Parameters
[in]certPointer to server certificate.
  • On UNIX systems with OpenSSL, a pointer to SSL_CTX.
  • On Windows systems whith SChannel, a pointer to CERT_CONTEXT.
Returns
True on success, false on error.

◆ serverSide()

bool ts::TLSContext::serverSide ( ) const
inline

Check if this is the server-side of the TLS connection.

Returns
True if this is the server-side of the TLS connection.

◆ provideClearData()

bool ts::TLSContext::provideClearData ( const void *  data,
size_t  size,
size_t &  ret_size 
)

Send clear user data over the TLS connection.

Most of the time, this results in a TLS protocol packet to be sent. If the user data are too long, only some of them can be sent in the next TLS protocol packet.

Parameters
[in]dataAddress of the clear user message to sent.
[in]sizeSize in bytes of the clear user message to sent.
[out]ret_sizeSize of data which where consumed. If ret_size is less than size, the rest shall be submitted later.
Returns
True on success, false on error.

◆ needSend()

bool ts::TLSContext::needSend ( ) const
inline

Check if some TLS protocol data must be sent.

The application must send the corresponding data and then call sendCompleted().

Returns
True if there are some TLS protocol data to send.

◆ getDataSizeToSend()

size_t ts::TLSContext::getDataSizeToSend ( ) const

Get the size in bytes of TLS protocol data which are ready to send.

Returns
Size in bytes of TLS protocol data which are ready to send.

◆ getDataToSend()

bool ts::TLSContext::getDataToSend ( ByteBlock tls_data)

Get TLS protocol data to send.

Parameters
[in,out]tls_dataBinary data to send over the wire are appended into tls_data.
Returns
True on success, false on error.

◆ needReceive()

bool ts::TLSContext::needReceive ( ) const
inline

Check if more TLS protocol data must be received in order to continue.

Returns
True if more TLS protocol data must be received in order to continue.

◆ provideReceivedData()

bool ts::TLSContext::provideReceivedData ( const void *  data,
size_t  size,
size_t &  ret_size,
ByteBlock clear_data 
)

Provide received TLS protocol data, collect clear data.

If the received data are too long, only some of them can be processed. In that case, it is possible that some data must be sent before accepting the rest of the received data.

Parameters
[in]dataAddress of the received data.
[in]sizeSize in bytes of the received data.
[out]ret_sizeSize of data which where consumed. If ret_size is less than size, the rest shall be submitted later.
[in,out]clear_dataIf any clear user data were extracted from the TLS protocol data, they are appended into clear_data.
Returns
True on success, false on error.

◆ eof()

bool ts::TLSContext::eof ( ) const
inline

Check if the input TLS stream is terminated (peer shutdown).

Returns
True if the input TLS stream is terminated.

◆ initShutdown()

bool ts::TLSContext::initShutdown ( bool  silent)

Generate a shutdown message to send to the peer.

Parameters
[in]silentIf true, do not report errors through the logger. This is typically useful when the socket is in some error condition and closing it is necessary although it may generate additional meaningless errors.
Returns
True on success, false on error.

◆ shutdowning()

bool ts::TLSContext::shutdowning ( ) const
inline

Check if a TLS shutdown was generated.

Returns
True if a TLS shutdown was generated.

◆ GetLibraryVersion()

static UString ts::TLSContext::GetLibraryVersion ( )
static

Get the version of the underlying SSL/TLS library.

Returns
The library version.

◆ report()

virtual Report & ts::ReporterBase::report ( ) const
overridevirtualinherited

Access the Report which is associated with this object.

Can be called from another thread only if the Report object is thread-safe.

Returns
A reference to the associated report.

Implements ts::ReporterInterface.

◆ setReport() [1/2]

Report * ts::ReporterBase::setReport ( Report report)
inherited

Associate this object with another Report to log errors.

Parameters
[in]reportWhere to report errors. The report object must remain valid as long as this object exists or setReport() is used with another Report object. If report is null, log messages are discarded.
Returns
The address of the previous Report object or a null pointer if there was none.

◆ setReport() [2/2]

ReporterBase * ts::ReporterBase::setReport ( ReporterBase delegate)
inherited

Associate this object with another ReporterBase to log errors.

Parameters
[in]delegateUse the report of another ReporterBase. If delegate is null, the previous explicit Report is used..
Returns
The address of the previous ReporterBase object or a null pointer if there was none.

◆ muteReport()

bool ts::ReporterBase::muteReport ( bool  mute)
inherited

Temporarily mute the associated report.

Parameters
[in]muteIt true, report() will return a null report (log messages are discarded), until muteReport() is invoked again with mute set to false.
Returns
Previous state of the mute field.

◆ SilentLevel()

static int ts::ReporterBase::SilentLevel ( bool  silent,
int  default_severity = Severity::Error 
)
inlinestaticinherited

Compute a log severity level from a "silent" parameter.

Some subclass methods have a "silent" parameter to avoid reporting errors which may be insignificant, typically when closing a device after an error, in which case the close operation may produce other errors if the previous error left the device in an inconsistent state. While those errors should not be displayed as errors, we still display them at debug level.

Parameters
[in]silentIf true, do not report errors, report debug messages instead.
[in]default_severityDefault severity, in non-silent mode (error by default).
Returns
Error when silent is false, Debug otherwise.

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