TSDuck v3.46-4806
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::TLSArgs Class Reference

Common arguments for TLS client and server usage. More...

#include <tsTLSArgs.h>

Inheritance diagram for ts::TLSArgs:
Collaboration diagram for ts::TLSArgs:

Public Types

using SuperClass = IPArgs
 Explicit definition of the superclass.
 

Public Member Functions

 TLSArgs (const UString &description=u"server", const UString &prefix=UString(), bool tls_default=false)
 Constructor.
 
virtual void defineClientArgs (Args &args) override
 Add some command line options for a client in an Args.
 
virtual void defineServerArgs (Args &args) override
 Add command line options for a server in an Args.
 
const UString & description () const
 Get the short description of the service, as specified in the constructor.
 
bool hasCertificate () const
 Check if enough parameters are provided to specify a certificate, depending on the operating system.
 
bool isAllowed (const IPAddress &client) const
 On the server side, check if a client address is allowed, based on sets of allowed and denied clients.
 
bool loadAllowedClients (Args &args, const UChar *option)
 Load the set of allowed clients from a command line (server side).
 
virtual bool loadClientArgs (Args &args, const UChar *server_option=nullptr) override
 Load arguments for a client from a command line.
 
bool loadDeniedClients (Args &args, const UChar *option)
 Load the set of denied clients from a command line (server side).
 
virtual bool loadServerArgs (Args &args, const UChar *server_option=nullptr) override
 Load arguments for a server from a command line.
 
const UString & prefix () const
 Get the option prefix, ready to use in other option names.
 
const UString & withTLS () const
 Get the help string which defines the condition of using SSL/TLS.
 

Public Attributes

IPAddressSet allowed_clients {}
 White-list of allowed incoming clients.
 
UString certificate_path {}
 TLS server certificate path.
 
UString certificate_store {}
 TLS server certificate store.
 
cn::milliseconds connection_timeout {0}
 Connection timeout in milliseconds (zero means none).
 
IPAddressSet denied_clients {}
 Black-list of denied incoming clients.
 
size_t ephemeral_rsa_bits = 0
 TLS server ephemeral certificate RSA kiey size in bits, when not zero.
 
bool insecure = false
 Do not verify TLS server's certificate.
 
UString key_path {}
 TLS server private key path.
 
cn::milliseconds receive_timeout {0}
 Reception timeout in milliseconds (zero means none).
 
bool reuse_port = true
 Reuse-port socket option.
 
IPSocketAddress server_addr {}
 Server address and port. The address is optional on server side.
 
UString server_name {}
 Server host name (required in addition to server address in some cases).
 
bool use_tls = false
 Use SSL/TLS.
 

Detailed Description

Common arguments for TLS client and server usage.

Can be set by fields or using command line options.

Constructor & Destructor Documentation

◆ TLSArgs()

ts::TLSArgs::TLSArgs ( const UString &  description = u"server",
const UString &  prefix = UString(),
bool  tls_default = false 
)

Constructor.

Parameters
[in]descriptionShort description of the TLS service. Example: "control port". Use no initial cap, no final dot.
[in]prefixOptional prefix for all command line options. Example: when prefix is "foo", the option –certificate-path becomes –foo-certificate-path.
[in]tls_defaultIf false (the default) TLS is not the default and the option –tls is defined to activate it. If true, TLS is the default and the option –no-tls is defined to deactivate it and use clear communication.

Member Function Documentation

◆ hasCertificate()

bool ts::TLSArgs::hasCertificate ( ) const

Check if enough parameters are provided to specify a certificate, depending on the operating system.

Returns
True if enough parameters are provided to specify a certificate.

◆ withTLS()

const UString & ts::TLSArgs::withTLS ( ) const
inline

Get the help string which defines the condition of using SSL/TLS.

The actual string depends if SSL/TLS is enabled by default or not.

Returns
A constant reference to the string "Without --[prefix-]no-tls" or "With --[prefix-]tls".

◆ defineServerArgs()

virtual void ts::TLSArgs::defineServerArgs ( Args &  args)
overridevirtual

Add command line options for a server in an Args.

No options is defined for server [addr:]port because the description is probably too specific. Same for lists of allowed and denied clients.

Parameters
[in,out]argsCommand line arguments to update.

Reimplemented from ts::IPArgs.

Reimplemented in ts::RestArgs.

◆ defineClientArgs()

virtual void ts::TLSArgs::defineClientArgs ( Args &  args)
overridevirtual

Add some command line options for a client in an Args.

No options is defined for server addr:port because the description is probably too specific.

Parameters
[in,out]argsCommand line arguments to update.

Reimplemented from ts::IPArgs.

Reimplemented in ts::RestArgs.

◆ loadServerArgs()

virtual bool ts::TLSArgs::loadServerArgs ( Args &  args,
const UChar *  server_option = nullptr 
)
overridevirtual

Load arguments for a server from a command line.

Args error indicator is set in case of incorrect arguments.

Parameters
[in,out]argsCommand line arguments.
[in]server_optionOptional name of an option which defines the server port and optional address.
Returns
True on success, false on error in argument line.

Reimplemented from ts::IPArgs.

Reimplemented in ts::RestArgs.

◆ loadClientArgs()

virtual bool ts::TLSArgs::loadClientArgs ( Args &  args,
const UChar *  server_option = nullptr 
)
overridevirtual

Load arguments for a client from a command line.

Args error indicator is set in case of incorrect arguments.

Parameters
[in,out]argsCommand line arguments.
[in]server_optionOptional name of an option which defines the server name and address.
Returns
True on success, false on error in argument line.

Reimplemented from ts::IPArgs.

Reimplemented in ts::RestArgs.

◆ loadAllowedClients()

bool ts::IPArgs::loadAllowedClients ( Args &  args,
const UChar *  option 
)
inlineinherited

Load the set of allowed clients from a command line (server side).

Parameters
[in,out]argsCommand line arguments.
[in]optionOption which defines the client addresses.
Returns
True on success, false on error in argument line.

◆ loadDeniedClients()

bool ts::IPArgs::loadDeniedClients ( Args &  args,
const UChar *  option 
)
inlineinherited

Load the set of denied clients from a command line (server side).

Parameters
[in,out]argsCommand line arguments.
[in]optionOption which defines the client addresses.
Returns
True on success, false on error in argument line.

◆ isAllowed()

bool ts::IPArgs::isAllowed ( const IPAddress &  client) const
inherited

On the server side, check if a client address is allowed, based on sets of allowed and denied clients.

Parameters
[in]clientIncoming client address.
Returns
True if the client is allowed, false if it is denied.

◆ description()

const UString & ts::IPArgs::description ( ) const
inlineinherited

Get the short description of the service, as specified in the constructor.

The result can be used in help text in subclasses for instance.

Returns
A constant reference to the description string.

◆ prefix()

const UString & ts::IPArgs::prefix ( ) const
inlineinherited

Get the option prefix, ready to use in other option names.

If the prefix was set to a non-empty string without trailing dash, the returned string contains a trailing dash. Example: when prefix was set to "foo" in the constructor, the returned value is "foo-"

Returns
A constant reference to the prefix string.

Member Data Documentation

◆ certificate_store

UString ts::TLSArgs::certificate_store {}

TLS server certificate store.

See also
TLSServerBase::setCertificateStore()

◆ certificate_path

UString ts::TLSArgs::certificate_path {}

TLS server certificate path.

See also
TLSServerBase::setCertificatePath()

◆ key_path

UString ts::TLSArgs::key_path {}

TLS server private key path.

See also
TLSServerBase::setKeyPath()

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