![]() |
TSDuck v3.43-4441
MPEG Transport Stream Toolkit
|
Implementation of a SSL/TLS server. More...
#include <tsTLSServer.h>
Public Types | |
using | SuperClass = TCPServer |
Reference to the superclass. | |
Public Member Functions | |
TLSServer () | |
Constructor. | |
TLSServer (const TLSArgs &args) | |
Constructor with initial arguments. | |
virtual bool | accept (TCPConnection &client, IPSocketAddress &addr, Report &report=(ts::CerrReport::Instance())) override |
Wait for an incoming client connection. | |
bool | bind (const IPSocketAddress &addr, Report &report=(ts::CerrReport::Instance())) |
Bind to a local address and port. | |
virtual bool | close (Report &report=(ts::CerrReport::Instance())) override |
Close the socket. | |
IP | generation () const |
Get the IP generation with which the socket was open. | |
const UString & | getCertificatePath () const |
Get the certificate path for the server. | |
const UString & | getCertificateStore () const |
Get the certificate store. | |
const UString & | getKeyPath () const |
Get the private key path for the server. | |
bool | getLocalAddress (IPSocketAddress &addr, Report &report=(ts::CerrReport::Instance())) |
Get local socket address. | |
SysSocketType | getSocket () const |
Get the underlying socket device handle (use with care). | |
bool | isOpen () const |
Check if socket is open. | |
virtual bool | listen (int backlog, Report &report=(ts::CerrReport::Instance())) override |
Start the server. | |
virtual bool | open (IP gen, Report &report=(ts::CerrReport::Instance())) override |
Open the socket. | |
bool | reusePort (bool reuse_port, Report &report=(ts::CerrReport::Instance())) |
Set the "reuse port" option. | |
void | setArgs (const TLSArgs &args) |
Set command line arguments for the server. | |
void | setCertificatePath (const UString &path) |
Set the certificate path for the server. | |
void | setCertificateStore (const UString &name) |
Set the certificate store. | |
bool | setKeepAlive (bool active, Report &report=(ts::CerrReport::Instance())) |
Set the "keep alive" option. | |
void | setKeyPath (const UString &path) |
Set the private key path for the server. | |
bool | setLingerTime (int seconds, Report &report=(ts::CerrReport::Instance())) |
Set the linger time option. | |
bool | setNoDelay (bool active, Report &report=(ts::CerrReport::Instance())) |
Set the "no delay" option. | |
bool | setNoLinger (Report &report=(ts::CerrReport::Instance())) |
Remove the linger time option. | |
bool | setReceiveBufferSize (size_t size, Report &report=(ts::CerrReport::Instance())) |
Set the receive buffer size. | |
bool | setReceiveTimeout (cn::milliseconds timeout, Report &report=(ts::CerrReport::Instance())) |
Set the receive timeout. | |
bool | setSendBufferSize (size_t size, Report &report=(ts::CerrReport::Instance())) |
Set the send buffer size. | |
bool | setTTL (int ttl, Report &report=(ts::CerrReport::Instance())) |
Set the Time To Live (TTL) option. | |
Protected Member Functions | |
bool | convert (IPAddress &addr, Report &report) const |
Convert an IP address to make it compatible with the socket IP generation. | |
bool | createSocket (IP gen, int type, int protocol, Report &report) |
Create the socket. | |
virtual void | declareOpened (SysSocketType sock, Report &report) override |
Set an open socket descriptor from a subclass. | |
virtual void | handleClosed (Report &report) |
This virtual method can be overriden by subclasses to be notified of close. | |
virtual void | handleOpened (Report &report) |
This virtual method can be overriden by subclasses to be notified of open. | |
Protected Attributes | |
std::recursive_mutex | _mutex {} |
Mutex protecting this object. | |
Implementation of a SSL/TLS server.
On UNIX systems (with OpenSSL):
To display the properties of the certificate:
On Windows:
To display the properties of the certificate:
A self-signed certificate is considered as invalid. So, make sure to ignore this error. With curl, use option –insecure or -k.
To view the certificate of a server using OpenSSL:
|
inline |
Constructor with initial arguments.
[in] | args | Initial TLS arguments. |
void ts::TLSServer::setArgs | ( | const TLSArgs & | args | ) |
Set command line arguments for the server.
[in] | args | TLS arguments. |
|
inline |
Set the certificate path for the server.
[in] | path | Path to the certificate.
|
|
inline |
Get the certificate path for the server.
|
inline |
Set the private key path for the server.
[in] | path | Path to the private key.
|
|
inline |
Get the private key path for the server.
|
inline |
Set the certificate store.
[in] | name |
|
|
inline |
Get the certificate store.
|
overridevirtual |
Start the server.
Here, starting the server means starting to listen to incoming client connections. Internally to the kernel, the incoming connections are queued up to backlog. When the method accept() is invoked and some incoming connections are already queued in the kernel, the oldest one is immediately accepted. Otherwise, accept() blocks until a new incoming connection arrives.
[in] | backlog | Maximum number of incoming connections which allowed to queue in the kernel until the next call to accept(). Note that this value is a minimum queue size. But the kernel may accept more. There is no guarantee that additional incoming connections will be rejected if more than backlog are already queueing. |
[in,out] | report | Where to report error. |
Reimplemented from ts::TCPServer.
|
overridevirtual |
Wait for an incoming client connection.
[out] | client | This object receives the new connection. Upon successful return from accept(), the TCPConnection object is a properly connected TCP session. Once the connection is completed, the TCPConnection objects on the client side and the server side are symmetric and can be used the same way. |
[out] | addr | This object receives the socket address of the client. If the server wants to filter client connections based on their IP address, it may use addr for that. |
[in,out] | report | Where to report error. |
Reimplemented from ts::TCPServer.
|
overridevirtual |
Close the socket.
[in,out] | report | Where to report error. |
Reimplemented from ts::TCPServer.
|
inherited |
Set the Time To Live (TTL) option.
[in] | ttl | The TTL value, ie. the maximum number of "hops" between routers before an IP packet is dropped. |
[in,out] | report | Where to report error. |
|
inherited |
Remove the linger time option.
[in,out] | report | Where to report error. |
|
inherited |
Set the linger time option.
[in] | seconds | Number of seconds to wait after shuting down the socket. |
[in,out] | report | Where to report error. |
|
inherited |
Set the "keep alive" option.
[in] | active | If true, the socket periodically sends "keep alive" packets when the connection is idle. |
[in,out] | report | Where to report error. |
|
inherited |
Set the "no delay" option.
[in] | active | If true, the socket immediately sends outgoing packets. By default, a TCP socket waits a small amount of time after a send() operation to get a chance to group outgoing data from successive send() operations into one single packet. |
[in,out] | report | Where to report error. |
|
inherited |
Bind to a local address and port.
The IP address part of the socket address must one of:
The port number part of the socket address must be one of:
[in] | addr | Local socket address to bind to. |
[in,out] | report | Where to report error. |
|
overridevirtualinherited |
Open the socket.
[in] | gen | IP generation, IPv4 or IPv6. If set to IP::Any, open an IPv6 socket (IPv4 connections allowed). |
[in,out] | report | Where to report error. |
Implements ts::Socket.
|
protectedvirtualinherited |
This virtual method can be overriden by subclasses to be notified of open.
All subclasses should explicitly invoke their superclass' handlers.
[in,out] | report | Where to report error. |
|
protectedvirtualinherited |
This virtual method can be overriden by subclasses to be notified of close.
All subclasses should explicitly invoke their superclass' handlers.
[in,out] | report | Where to report error. |
Reimplemented in ts::TCPConnection.
|
overrideprotectedvirtualinherited |
Set an open socket descriptor from a subclass.
This method is used by a server to declare that a client socket has just become opened.
[in] | sock | New socket descriptor. |
[in,out] | report | Where to report error. |
Reimplemented from ts::Socket.
|
inlineinherited |
Check if socket is open.
|
inlineinherited |
Get the IP generation with which the socket was open.
|
inherited |
Set the send buffer size.
[in] | size | Send buffer size in bytes. |
[in,out] | report | Where to report error. |
|
inherited |
Set the receive buffer size.
[in] | size | Receive buffer size in bytes. |
[in,out] | report | Where to report error. |
|
inherited |
Set the receive timeout.
[in] | timeout | Receive timeout in milliseconds. If negative or zero, receive timeout is not used, reception waits forever. |
[in,out] | report | Where to report error. |
|
inherited |
Set the "reuse port" option.
[in] | reuse_port | If true, the socket is allowed to reuse a local UDP port which is already bound. |
[in,out] | report | Where to report error. |
|
inherited |
Get local socket address.
[out] | addr | Local socket address of the connection. |
[in,out] | report | Where to report error. |
|
inlineinherited |
Get the underlying socket device handle (use with care).
This method is reserved for low-level operations and should not be used by normal applications.
Convert an IP address to make it compatible with the socket IP generation.
addr | [in,out] The address to convert. | |
[in,out] | report | Where to report error. |