Mixes for Privacy and Anonymity in the Internet
Public Member Functions | Private Member Functions | Private Attributes
CATLSClientSocket Class Reference
Inheritance diagram for CATLSClientSocket:
CASocket CAClientSocket

List of all members.

Public Member Functions

 CATLSClientSocket ()
 ~CATLSClientSocket ()
SINT32 sendFully (const UINT8 *buff, UINT32 len)
 Sends all data over the network.
SINT32 send (const UINT8 *buff, UINT32 len)
 Sends all data over the network.
SINT32 receive (UINT8 *buff, UINT32 len)
 Will receive some bytes from the socket.
SINT32 close ()
 Shuts down the socket.
SINT32 connect (CASocketAddr &psa, UINT32 msTimeout)
 Establishes the actual TCP/IP connection and performs the TLS handshake.
SINT32 setServerCertificate (CACertificate *pCert)
 Sets the Certifcate we accept as server identification.

Private Member Functions

SINT32 doTLSConnect (CASocketAddr &psa)
 Does the TLS handshake.

Private Attributes

SSL * m_pSSL
SSL_CTX * m_pCtx
CACertificatem_pRootCert
bool m_bConnectedTLS
 is the TLS layer established ?

Constructor & Destructor Documentation

References close(), m_pCtx, and m_pRootCert.


Member Function Documentation

Shuts down the socket.

This is an overridden virtual function which shuts down the TLS layer first

Reimplemented from CASocket.

References m_bConnectedTLS, and m_pSSL.

Referenced by connect(), doTLSConnect(), CAAccountingBIInterface::initBIConnection(), CAAccountingBIInterface::terminateBIConnection(), and ~CATLSClientSocket().

Establishes the actual TCP/IP connection and performs the TLS handshake.

Establishes the TCP/IP connection, performs the TLS handshake and checks the server certificate validity.

References close(), CASocket::connect(), doTLSConnect(), and E_SUCCESS.

Referenced by CAAccountingBIInterface::initBIConnection().

Does the TLS handshake.

The TCP Connection must be established first and openSSL library must be initialized

References close(), E_SUCCESS, E_UNKNOWN, CACertificate::getX509(), m_bConnectedTLS, m_pCtx, m_pRootCert, m_pSSL, CASocket::m_Socket, and CAMsg::printMsg().

Referenced by connect().

SINT32 CATLSClientSocket::receive ( UINT8 buff,
UINT32  len 
) [virtual]

Will receive some bytes from the socket.

May block or not depending on whatever this socket was set to blocking or non-blocking mode. Warning: If socket is in blocking mode and receive is called, receive will block until some data is available, EVEN IF AN OTHER THREAD WILL CLOSE THIS SOCKET!

Parameters:
buffthe buffer which get the received data
lensize of buff
Returns:
SOCKET_ERROR if an error occured
Return values:
E_AGAIN,ifsocket was in non-blocking mode and receive would block or a timeout was reached
0if socket was gracefully closed
Returns:
the number of bytes received (always >0)

Reimplemented from CASocket.

References E_AGAIN, m_pSSL, CAMsg::printMsg(), SOCKET_ERROR, and strerror().

SINT32 CATLSClientSocket::send ( const UINT8 buff,
UINT32  len 
) [virtual]

Sends all data over the network.

This may block, until all data was sent.

Parameters:
buffthe buffer of data to send
lencontent length
Return values:
E_UNKNOWNif an error occured
E_SUCCESSif successfull

Reimplemented from CASocket.

References E_AGAIN, E_SUCCESS, m_pSSL, CAMsg::printMsg(), SOCKET_ERROR, and strerror().

SINT32 CATLSClientSocket::sendFully ( const UINT8 buff,
UINT32  len 
) [virtual]

Sends all data over the network.

This may block, until all data was sent.

Parameters:
buffthe buffer of data to send
lencontent length
Return values:
E_UNKNOWNif an error occured
E_SUCCESSif successfull

Reimplemented from CASocket.

References E_SUCCESS, E_UNKNOWN, and m_pSSL.

Sets the Certifcate we accept as server identification.

Init the SSL object.

Set to NULL if you do not want any certificate checking. At the moment only a depth of verification path of zero or one is supported!

SSL_init_library() must be called before this!

References CACertificate::clone(), E_SUCCESS, and m_pRootCert.

Referenced by CAAccountingBIInterface::initBIConnection().


Member Data Documentation

is the TLS layer established ?

Referenced by CATLSClientSocket(), close(), and doTLSConnect().

SSL_CTX* CATLSClientSocket::m_pCtx [private]
SSL* CATLSClientSocket::m_pSSL [private]