class tcpsocket::SSLSocket

Implements a Secure Sockets Layer socket connection

Child Classes

Implements a Secure Sockets Layer socket connection

Direct child classes:
SSLServerSocket

Inheritance:


Public Methods

[more] SSLSocket(const char* host, short port, SSLContext* pCtx) throw(SSLSocketException, SocketException)
Constructs the socket and opens a connection to a server
[more] SSLSocket()
Constructs the SSLSocket object, usable for copy destinations
[more] SSLSocket(int socket_handle, SSLContext* pCtx, con_type type)
Constructs the SSLSocket and uses the provided socket handle for communications
[more] SSLSocket(const SSLSocket& s)
Copy constructor, copies the socket handle
[more]Socket* clone() const
Clones this object
[more]void close() throw(SocketException)
Closes the socket handle, and frees the SSL structures
[more]SSLContext* getCTX()
Gets the SSLContext Object associated with the socket
[more]std::string getErrorMessage()
Gets the SSL error message
[more]X509Certificate* getPeerCertificate()
Retreives the certificate of the peer
Note: The returned object must be freed by the caller
[more]void* getSSL()
Gets the SSL object cast as void
[more]int getVerifyResult()
Gets the result of performing a certificate verification
[more]SSLSocket& operator=(const SSLSocket& s)
Copy oeprator, copies the socket handle and SSL information
[more]size_t receive(char* readBuffer, size_t length) throw(SSLSocketException)
Receives data from the socket.
[more]size_t receiveSome(char* readBuffer, size_t length) throw(SSLSocketException)
Receives data from the socket.
[more]size_t send(const char* sendBuffer, size_t length) throw(SSLSocketException)
Sends data over the socket.
[more] ~SSLSocket()
Destroys the SSL socket

Public Members

[more]enum con_type
An enumeration SSL Conneciton types indicating whether the object will be used as a client or server

Inherited from Socket:

Public Methods

ovirtual int getSocket()
obool getThrowOnClosed()
ovoid setThrowOnClosed(bool throwOnClose)

Protected Fields

oint m_socket

Member Documentation


enum con_type
An enumeration SSL Conneciton types indicating whether the object will be used as a client or server


con_client
A client connection


con_server
A server connection


SSLSocket ()
Constructs the SSLSocket object, usable for copy destinations


SSLSocket (int socket_handle, SSLContext* pCtx, con_type type)
Constructs the SSLSocket and uses the provided socket handle for communications
Parameters:
socket_handle - [in] A previously created socket handle
pCtx - [in] A previously created SSLContext
type - [in, default = con_client] Indicates wether the socket is a client or server


SSLSocket (const SSLSocket& s)
Copy constructor, copies the socket handle
Parameters:
s - [in] The source socket


SSLSocket (const char* host, short port, SSLContext* pCtx) throw(SSLSocketException, SocketException)
Constructs the socket and opens a connection to a server
Parameters:
host - [in] The address of the server or DNS name
- port [in] The TCP port to connect to
version - [in] The SSL Protocol version to use


~SSLSocket ()
Destroys the SSL socket


SSLSocket& operator= (const SSLSocket& s)
Copy oeprator, copies the socket handle and SSL information
Parameters:
s - [in] The source socket
Returns:
A reference tot his object.


size_t send (const char* sendBuffer, size_t length) throw(SSLSocketException)
Sends data over the socket. Sends exactly length bytes.
Throws:
SocketException if the connection was closed and the throw on close flag was set.
Parameters:
sendBuffer - [in] A buffer containing the data to be sent
length - [in] The number of bytes in the buffer
Returns:
The number of bytes sent, -1 on error, and 0 if the connection was closed


size_t receive (char* readBuffer, size_t length) throw(SSLSocketException)
Receives data from the socket. Receives exactly length bytes or less if the socket is closed early.
Throws:
SocketException if the connection was closed and the throw on close flag was set.
Parameters:
sendBuffer - [out] A buffer receiving the data
length - [in] The maximum number of bytes in the buffer
Returns:
The number of bytes received, -1 on error, and 0 if the connection was closed


size_t receiveSome (char* readBuffer, size_t length) throw(SSLSocketException)
Receives data from the socket. Receives upto length bytes.
Throws:
SocketException if the connection was closed and the throw on close flag was set.
Parameters:
sendBuffer - [out] A buffer receiving the data
length - [in] The maximum number of bytes in the buffer
Returns:
The number of bytes received, -1 on error, and 0 if the connection was closed


void close () throw(SocketException)
Closes the socket handle, and frees the SSL structures


Socket* clone () const
Clones this object
Returns:
a new SSLSocket constructed from this object.


X509Certificate* getPeerCertificate ()
Retreives the certificate of the peer
Note: The returned object must be freed by the caller
Returns:
the X509 cetificate of the peer.


int getVerifyResult ()
Gets the result of performing a certificate verification
Returns:
The verify result.


std::string getErrorMessage ()
Gets the SSL error message
Returns:
The SSL error message


void* getSSL ()
Gets the SSL object cast as void
Returns:
the SSL object cast as void*.


SSLContext* getCTX ()
Gets the SSLContext Object associated with the socket
Returns:
The SSLCOntext Object associated with the socket.

Table of Contents HTML hierarchy of classes or Java


Safmq Documentation, copyright (c) 2004-2010 Matthew J. Battey, Licensed Under Apache License Ver 2.0
Powered By: Get SAFMQ: Store and Forward Message Queue at SourceForge.net. Fast, secure and Free Open Source software downloads