Context of a TLS connection.
More...
#include <tsTLSContext.h>
|
| | 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 ¶ms) |
| | 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 Report & | report () 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.
|
| |
| Report * | setReport (Report *report) |
| | Associate this object with another Report to log errors.
|
| |
| ReporterBase * | setReport (ReporterBase *delegate) |
| | Associate this object with another ReporterBase to log errors.
|
| |
| bool | shutdowning () const |
| | Check if a TLS shutdown was generated.
|
| |
Context of a TLS connection.
This is state machine working on pure data, non-blocking, without network access.
◆ TLSContext() [1/2]
| ts::TLSContext::TLSContext |
( |
Report * |
report | ) |
|
|
explicit |
Constructor.
- Parameters
-
| [in] | report | Where 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]
Constructor.
- Parameters
-
| [in] | delegate | Use the report of another ReporterBase. If delegate is null, log messages are discarded. |
◆ initClient()
Initialize the client side of a connection.
- Parameters
-
| [in] | params | TLS 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] | cert | Pointer 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] | data | Address of the clear user message to sent. |
| [in] | size | Size in bytes of the clear user message to sent. |
| [out] | ret_size | Size 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_data | Binary 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] | data | Address of the received data. |
| [in] | size | Size in bytes of the received data. |
| [out] | ret_size | Size of data which where consumed. If ret_size is less than size, the rest shall be submitted later. |
| [in,out] | clear_data | If 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] | silent | If 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]
Associate this object with another Report to log errors.
- Parameters
-
| [in] | report | Where 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]
Associate this object with another ReporterBase to log errors.
- Parameters
-
| [in] | delegate | Use 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] | mute | It 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] | silent | If true, do not report errors, report debug messages instead. |
| [in] | default_severity | Default 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: