gloox
1.0.1
|
#include <connectiontls.h>
Public Member Functions | |
ConnectionTLS (ConnectionDataHandler *cdh, ConnectionBase *conn, const LogSink &log) | |
ConnectionTLS (ConnectionBase *conn, const LogSink &log) | |
virtual | ~ConnectionTLS () |
void | setCACerts (const StringList &cacerts) |
const CertInfo & | fetchTLSInfo () const |
void | setClientCert (const std::string &clientKey, const std::string &clientCerts) |
void | setConnectionImpl (ConnectionBase *connection) |
void | registerTLSHandler (TLSHandler *th) |
virtual ConnectionError | connect () |
virtual ConnectionError | recv (int timeout=-1) |
virtual bool | send (const std::string &data) |
virtual ConnectionError | receive () |
virtual void | disconnect () |
virtual void | cleanup () |
virtual void | getStatistics (long int &totalIn, long int &totalOut) |
virtual void | handleReceivedData (const ConnectionBase *connection, const std::string &data) |
virtual void | handleConnect (const ConnectionBase *connection) |
virtual void | handleDisconnect (const ConnectionBase *connection, ConnectionError reason) |
virtual ConnectionBase * | newInstance () const |
virtual void | handleEncryptedData (const TLSBase *, const std::string &data) |
virtual void | handleDecryptedData (const TLSBase *, const std::string &data) |
virtual void | handleHandshakeResult (const TLSBase *base, bool success, CertInfo &certinfo) |
Public Member Functions inherited from TLSHandler | |
virtual | ~TLSHandler () |
Public Member Functions inherited from ConnectionBase | |
ConnectionBase (ConnectionDataHandler *cdh) | |
virtual | ~ConnectionBase () |
ConnectionState | state () const |
void | registerConnectionDataHandler (ConnectionDataHandler *cdh) |
void | setServer (const std::string &server, int port=-1) |
const std::string & | server () const |
int | port () const |
virtual int | localPort () const |
virtual const std::string | localInterface () const |
Public Member Functions inherited from ConnectionDataHandler | |
virtual | ~ConnectionDataHandler () |
Protected Member Functions | |
virtual TLSBase * | getTLSBase (TLSHandler *th, const std::string server) |
Additional Inherited Members | |
Protected Attributes inherited from ConnectionBase | |
ConnectionDataHandler * | m_handler |
ConnectionState | m_state |
std::string | m_server |
int | m_port |
This is an implementation of a TLS/SSL connection.
You should not need to use this function directly. However, you can use it to connect to the legacy Jabber SSL port, 5223.
Usage:
Due to the need for handshaking data to be sent/received before the connection is fully established, be sure not to use the connection until ConnectionDataHandler::handleConnect() of the specified ConnectionDataHandler is called.
Definition at line 51 of file connectiontls.h.
ConnectionTLS | ( | ConnectionDataHandler * | cdh, |
ConnectionBase * | conn, | ||
const LogSink & | log | ||
) |
Constructs a new ConnectionTLS object.
cdh | The ConnectionDataHandler that will be notified of events from this connection |
conn | A transport connection. It should be configured to connect to the server and port you wish to make the encrypted connection to. ConnectionTLS will own the transport connection and delete it in its destructor. |
log | The log target. Obtain it from ClientBase::logInstance(). |
Definition at line 22 of file connectiontls.cpp.
ConnectionTLS | ( | ConnectionBase * | conn, |
const LogSink & | log | ||
) |
Constructs a new ConnectionTLS object.
conn | A transport connection. It should be configured to connect to the server and port you wish to make the encrypted connection to. ConnectionTLS will own the transport connection and delete it in its destructor. |
log | The log target. Obtain it from ClientBase::logInstance(). |
Definition at line 31 of file connectiontls.cpp.
|
virtual |
Virtual Destructor.
Definition at line 39 of file connectiontls.cpp.
|
virtual |
This function is called after a disconnect to clean up internal state. It is also called by ConnectionBase's destructor.
Reimplemented from ConnectionBase.
Definition at line 126 of file connectiontls.cpp.
|
virtual |
Used to initiate the connection.
Implements ConnectionBase.
Definition at line 56 of file connectiontls.cpp.
|
virtual |
Disconnects an established connection. NOOP if no active connection exists.
Implements ConnectionBase.
Definition at line 118 of file connectiontls.cpp.
|
inline |
This function is used to retrieve certificate and connection info of a encrypted connection.
Definition at line 94 of file connectiontls.h.
|
virtual |
Returns current connection statistics.
totalIn | The total number of bytes received. |
totalOut | The total number of bytes sent. |
Implements ConnectionBase.
Definition at line 136 of file connectiontls.cpp.
|
inlineprotectedvirtual |
Returns a TLS object (client). Reimplement to change the type of the object.
Reimplemented in ConnectionTLSServer.
Definition at line 178 of file connectiontls.h.
|
virtual |
This function is called when e.g. the raw TCP connection was established.
connection | The connection. |
Implements ConnectionDataHandler.
Definition at line 156 of file connectiontls.cpp.
|
virtual |
Reimplement this function to receive decrypted data from a TLSBase implementation.
base | The encryption implementation which called this function. |
data | The decrypted data (e.g. to parse). |
Implements TLSHandler.
Definition at line 176 of file connectiontls.cpp.
|
virtual |
This connection is called when e.g. the raw TCP connection was closed.
connection | The connection. |
reason | The reason for the disconnect. |
Implements ConnectionDataHandler.
Definition at line 162 of file connectiontls.cpp.
|
virtual |
Reimplement this function to receive encrypted data from a TLSBase implementation.
base | The encryption implementation which called this function. |
data | The encrypted data (e.g. to send over the wire). |
Implements TLSHandler.
Definition at line 170 of file connectiontls.cpp.
Reimplement this function to receive the result of a TLS handshake.
base | The encryption implementation which called this function. |
success | Whether or not the handshake was successful. |
certinfo | Information about the server's certificate. |
Implements TLSHandler.
Definition at line 186 of file connectiontls.cpp.
|
virtual |
This function is called for received from the underlying transport.
connection | The connection that received the data. |
data | The data received. |
Implements ConnectionDataHandler.
Definition at line 150 of file connectiontls.cpp.
|
virtual |
This function returns a new instance of the current ConnectionBase-derived object. The idea is to be able to 'clone' ConnectionBase-derived objects without knowing of what type they are exactly.
Implements ConnectionBase.
Reimplemented in ConnectionTLSServer.
Definition at line 142 of file connectiontls.cpp.
|
virtual |
Use this function to put the connection into 'receive mode', i.e. this function returns only when the connection is terminated.
Implements ConnectionBase.
Definition at line 110 of file connectiontls.cpp.
|
virtual |
Use this periodically to receive data from the socket.
timeout | The timeout to use for select in microseconds. Default of -1 means blocking. |
Implements ConnectionBase.
Definition at line 87 of file connectiontls.cpp.
|
inline |
Registers an TLSHandler derived object. Only the handleHandshakeResult() function will be used after a handshake took place. You can review certificate info there.
th | The TLSHandler to register. |
Definition at line 128 of file connectiontls.h.
|
virtual |
Use this function to send a string of data over the wire. The function returns only after all data has been sent.
data | The data to send. |
Implements ConnectionBase.
Definition at line 101 of file connectiontls.cpp.
|
inline |
Use this function to set a number of trusted root CA certificates which shall be used to verify a servers certificate.
cacerts | A list of absolute paths to CA root certificate files in PEM format. |
Definition at line 84 of file connectiontls.h.
|
inline |
Use this function to set the user's certificate and private key. The certificate will be presented to the server upon request and can be used for SASL EXTERNAL authentication. The user's certificate file should be a bundle of more than one certificate in PEM format. The first one in the file should be the user's certificate, each cert following that one should have signed the previous one.
clientKey | The absolute path to the user's private key in PEM format. |
clientCerts | A path to a certificate bundle in PEM format. |
Definition at line 108 of file connectiontls.h.
void setConnectionImpl | ( | ConnectionBase * | connection | ) |
Sets the transport connection.
connection | The transport connection to use. |
Definition at line 45 of file connectiontls.cpp.