Home | C-Bits Package Documentation | Project Page |
#include <SSLSocket.h>
Collaboration diagram for cbits::SSLSocket:
Public Types | |
typedef SSL * | SSL_PTR |
\typedef A type definition used with the cbits::SSLSocket-to- OpenSSL SSL conversion operator. More... | |
Public Methods | |
SSLSocket (const std::string &host, const int port, SSLContext *const ctxt=0, const bool now=true) throw ( SocketException ) | |
Construct a SSL-enabled socket. More... | |
SSLSocket (const char *host, const int port, SSLContext *const ctxt=0, const bool now=true) throw ( SocketException ) | |
Construct a SSL-enabled socket. More... | |
virtual | ~SSLSocket () |
Destructor. More... | |
virtual void | connect () throw (SocketException) |
virtual const ssize_t | read (char *const buffer, const int buflen, int *const error=0, const long int msec=0) throw ( SocketException ) |
virtual const ssize_t | receive (char *const buffer, const int buflen, const long int msec=0, int *const error=0) throw ( SocketException ) |
virtual const ssize_t | readLine (std::string &buffer, const std::string &delim, int *const error=0, const long int msec=0) throw ( SocketException ) |
First try to satisfy the read request from the SSL buffer. More... | |
virtual const ssize_t | write (const char *buffer, const long buflen, int *const error=0, const long int msec=0) throw ( SocketException ) |
virtual const ssize_t | send (const char *buffer, const long buflen, int *const error=0, const long int msec=0) throw ( SocketException ) |
const SSLPeer & | getPeer () const throw ( SocketException ) |
Access information about the SSL peer. More... | |
operator SSL_PTR () | |
Type conversion operator to allow a cbits::SSLSocket instance to be used where an OpenSSL SSL object is required. More... | |
Static Public Methods | |
SSLSocket * | create (const socket_t fd, SSLContext *const ctxt=0) throw ( SocketException ) |
Create a SSL-enabled socket instance from an existing socket file descriptor. More... | |
void | setGlobalContext (SSLContext *gctx) throw ( SSLContextException ) |
Set a SSL context to be used by ALL new SSLSocket instances. More... | |
Protected Methods | |
SSLSocket (const socket_t fd, SSLContext *const ctxt=0) throw ( SocketException ) | |
Protected constructor for wrapping a socket descriptor in an cbits::SSLSocket object. More... | |
Protected Attributes | |
bool | _ssl_is_connected |
A state flag that is set to true after the SSL handshake has successfully completed. More... | |
Private Methods | |
void | set_bio (const socket_t fd) throw ( SocketException ) |
Wrap the underlying network socket in an OpenSSL socket BIO object. More... | |
Private Attributes | |
BIO * | _bio |
The OpenSSL BIO object that wraps the low-level network socket connection. More... | |
SSLContext * | _ctxt |
The SSL context for this SSL connection. More... | |
SSL * | _ssl |
The OpenSSL SSL object representing this SSL connection. More... | |
SSLPeer * | _peer |
The SSL peer if the SSL connection is complete. More... | |
CriticalSection | _csect |
Critical section used to synchronize access to non-read/write specific code. More... | |
CriticalSection | _read_csect |
Critical section object used to prevent multiple threads from simultaneously reading from this SSL socket. More... | |
CriticalSection | _write_csect |
Critical section object used to prevent multiple threads from simultaneously writing to this SSL socket. More... | |
Static Private Attributes | |
SSLContext * | _global_ctxt = 0 |
The global, default SSL context, if set. More... |
The OpenSSL library (http://www.openssl.org) is used to provide SSL-related functionality and X.509 certificate handling.
The current version of this class is a minimal implementation. Overtime, more of the power available via OpenSSL will become visible in its interface.
From the user's perspective, a cbits::SSLSocket is (in principle) identical to a cbits::Socket in terms of functionality after the network connection has been established and the SSL handshake has succeeded.
However, all SSL sockets have to be created within a particular SSL context that defines parameters and data used during the SSL handshake, such as what ciphers are allowed (or not) and the location of relevant X.509 certificates.
The cbits::SSLContext class is used to represent an SSL security context for establishing SSL network connections. An instance of cbits::SSLContext should be provided to the cbits::SSLSocket constructor or set globally, in advance, for all (future) SSLSocket instances via the cbits::SSLSocket::setGlobalContext method.
Other methods in cbits::SSLSocket not inherited from cbits::Socket include those related to accessing the security credentials of the SSL peer (e.g. see cbits::SSLPeer).
|
\typedef A type definition used with the cbits::SSLSocket-to- OpenSSL SSL conversion operator.
|
|
Construct a SSL-enabled socket.
|
|
Construct a SSL-enabled socket.
|
|
Destructor. Close the network connection and destroy this socket instance. |
|
Protected constructor for wrapping a socket descriptor in an cbits::SSLSocket object.
|
|
|
|
Create a SSL-enabled socket instance from an existing socket file descriptor. An SSL context must be specified for the new socket.
|
|
Access information about the SSL peer.
|
|
Type conversion operator to allow a cbits::SSLSocket instance to be used where an OpenSSL SSL object is required.
|
|
|
|
First try to satisfy the read request from the SSL buffer. If no data or not enough is returned, then enter the loop below to wait for data on the socket before calling SSL_read again. |
|
|
|
|
|
Wrap the underlying network socket in an OpenSSL socket BIO object.
|
|
Set a SSL context to be used by ALL new SSLSocket instances. This may be overridden for individual SSLSocket instances by supplying a different context to the SSLSocket constructor when the SSLSocket is created.
|
|
|
|
The OpenSSL BIO object that wraps the low-level network socket connection. This BIO object is in turn wrapped by an OpenSSL SSL object. |
|
Critical section used to synchronize access to non-read/write specific code.
|
|
The SSL context for this SSL connection.
|
|
The global, default SSL context, if set.
|
|
The SSL peer if the SSL connection is complete.
|
|
Critical section object used to prevent multiple threads from simultaneously reading from this SSL socket.
|
|
The OpenSSL SSL object representing this SSL connection.
|
|
A state flag that is set to true after the SSL handshake has successfully completed.
|
|
Critical section object used to prevent multiple threads from simultaneously writing to this SSL socket.
|
|
|