Dv::Ssl::Socket Class Reference

An iostream derived from Dv::Net::Socket. More...

#include <sslsocket.h>

Inheritance diagram for Dv::Ssl::Socket:

Inheritance graph
[legend]
Collaboration diagram for Dv::Ssl::Socket:

Collaboration graph
[legend]
List of all members.

Public Types

enum  { SSL_CONNECTION_FAILED = -30, SSL_ACCEPT_FAILED = -31 }
 Extra error codes (see Dv::Net::Socket) for SSL connections. More...

Public Member Functions

 Socket (Context &context, const std::string &host, int port, size_t bufsize=1024, int delay=0, unsigned int min_debug_level=0, Debugable *debug_master=0)
 Constructor.
 ~Socket ()
 Destructor.
void * ssl () const
 Return SSL* pointer, opaque to avoid inclusion of openssl header files.
const char * cipher () const
 Return string representation of used cipher.
std::string strerror () const
 Overrides Dv::Net::Socket::strerror.

Private Member Functions

 Socket (Context &context, int fd, size_t bufsize=1024, int delay=0, unsigned int min_debug_level=0, Debugable *debug_master=0)
 Constructor version used by Dv::Ssl::Socket::fs2socket.

Static Private Member Functions

static Dv::shared_ptr< Dv::Ssl::Socketfd2sslsocket (Dv::Ssl::Context &ctxt, int fd, size_t bufsz=1024, int delay=0, unsigned int min_debug_level=0, Debugable *debug_master=0)
 This function is used internally by Dv::Ssl::ServerSocket::accept.

Private Attributes

Contextcontext_
 Associated SSL context.
Buffersslbuf_
 Associated streambuf.

Friends

class Dv::Ssl::ServerSocket
 Dv::Ssl::ServerSocket is a friend.

Detailed Description

An iostream derived from Dv::Net::Socket.

Example usage:

 Dv::Ssl::ContextV23 context;
 Dv::Ssl::Socket client(context, "host.domain", 9999);
 
 if (!client) {
   std::cerr << "connection failed: " << client.strerror() << endl;
   return 1;
 }

 Dv::Ssl::X509Certificate cert(client);
 std::cout << "client: certificate name = " << cert.name() << std::endl
   << "client: certificate issuer = " << cert.issuer() << std::endl;

 const std::string out("hello world");
 client << out << std::endl;

 std::string line;
 std::getline(client, line);
 if (line!=out) {
   std::cerr << "Client expected \"" << out << "\", got \"" << line << "\"" << std::endl;
   return 1;
 }

 std::cout << "Client exit status:" << client.strerror() << std::endl;
 return client.error();

Definition at line 40 of file sslsocket.h.


Member Enumeration Documentation

anonymous enum

Extra error codes (see Dv::Net::Socket) for SSL connections.

Enumerator:
SSL_CONNECTION_FAILED 
SSL_ACCEPT_FAILED 

Definition at line 45 of file sslsocket.h.


Constructor & Destructor Documentation

Dv::Ssl::Socket::Socket ( Context context,
const std::string &  host,
int  port,
size_t  bufsize = 1024,
int  delay = 0,
unsigned int  min_debug_level = 0,
Debugable debug_master = 0 
)

Constructor.

The Dv::Ssl::Context parameter need not contain private key or certificate file information since it is not used.

Parameters:
context existing Dv::Ssl::Context object.
host name of host to connect to
port on host to connect to
bufsize size of input and output buffers
delay (in milliseconds) time allowed for any I/O operation to complete. A value of 0 means ``wait forever''. Note that timedout() makes no sense if delay is 0.
min_debug_level if a debug_master is connected, logging info will only be written if the master's level is at least min_debug_level
debug_master from where debug info will be taken
See also:
Dv::DebugSlave
Warning:
the Dv::Ssl::Socket object does not own the Dv::Ssl::Context

Dv::Ssl::Socket::~Socket (  )  [virtual]

Destructor.

Reimplemented from Dv::Net::Socket.

Dv::Ssl::Socket::Socket ( Context context,
int  fd,
size_t  bufsize = 1024,
int  delay = 0,
unsigned int  min_debug_level = 0,
Debugable debug_master = 0 
) [private]

Constructor version used by Dv::Ssl::Socket::fs2socket.

Parameters:
context existing Dv::Ssl::Context object.
fd underlying file descriptor
bufsize size of input and output buffer
delay (in milliseconds) time allowed for any I/O operation to complete. A value of 0 means ``wait forever''. Note that timedout() makes no sense if delay is 0.
min_debug_level if a debug_master is connected, logging info will only be written if the master's level is at least min_debug_level
debug_master from where debug info will be taken
See also:
Dv::DebugSlave
Warning:
the Dv::Ssl::Socket object does not own the Dv::Ssl::Context


Member Function Documentation

void* Dv::Ssl::Socket::ssl (  )  const

Return SSL* pointer, opaque to avoid inclusion of openssl header files.

Returns:
pointer to underlying SSL structure

const char* Dv::Ssl::Socket::cipher (  )  const

Return string representation of used cipher.

Returns:
pointer to string representation of used cypher

std::string Dv::Ssl::Socket::strerror (  )  const [virtual]

Overrides Dv::Net::Socket::strerror.

Returns:
string representation of last error.

Reimplemented from Dv::Net::Socket.

static Dv::shared_ptr<Dv::Ssl::Socket> Dv::Ssl::Socket::fd2sslsocket ( Dv::Ssl::Context ctxt,
int  fd,
size_t  bufsz = 1024,
int  delay = 0,
unsigned int  min_debug_level = 0,
Debugable debug_master = 0 
) [static, private]

This function is used internally by Dv::Ssl::ServerSocket::accept.

Parameters:
ctxt existing Dv::Ssl::Context object.
fd underlying file descriptor
bufsz size of input and output buffer
delay (in milliseconds) time allowed for any I/O operation to complete. A value of 0 means ``wait forever''. Note that timedout() makes no sense if delay is 0.
min_debug_level if a debug_master is connected, logging info will only be written if the master's level is at least min_debug_level
debug_master from where debug info will be taken
See also:
Dv::DebugSlave
Warning:
the Dv::Ssl::Socket object does not own the Dv::Ssl::Context


Friends And Related Function Documentation

friend class Dv::Ssl::ServerSocket [friend]

Dv::Ssl::ServerSocket is a friend.

Definition at line 42 of file sslsocket.h.


Member Data Documentation

Context& Dv::Ssl::Socket::context_ [private]

Associated SSL context.

Definition at line 111 of file sslsocket.h.

Buffer* Dv::Ssl::Socket::sslbuf_ [private]

Associated streambuf.

Definition at line 113 of file sslsocket.h.


The documentation for this class was generated from the following file:
dvssl-0.6.1 [15 March, 2008]