#include <sslsocket.h>
Inheritance diagram for Dv::Ssl::Socket:
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::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) |
This function is used internally by Dv::Ssl::ServerSocket::accept. | |
Private Attributes | |
Context & | context_ |
Associated SSL context. | |
Buffer * | sslbuf_ |
Associated streambuf. | |
Friends | |
class | Dv::Ssl::ServerSocket |
Dv::Ssl::ServerSocket is a friend. |
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.
anonymous enum |
Extra error codes (see Dv::Net::Socket) for SSL connections.
Definition at line 45 of file sslsocket.h.
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.
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 |
Dv::Ssl::Socket::~Socket | ( | ) | [virtual] |
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.
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 |
void* Dv::Ssl::Socket::ssl | ( | ) | const |
Return SSL* pointer, opaque to avoid inclusion of openssl header files.
const char* Dv::Ssl::Socket::cipher | ( | ) | const |
Return string representation of used cipher.
std::string Dv::Ssl::Socket::strerror | ( | ) | const [virtual] |
Overrides Dv::Net::Socket::strerror.
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.
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 |
friend class Dv::Ssl::ServerSocket [friend] |
Context& Dv::Ssl::Socket::context_ [private] |
Buffer* Dv::Ssl::Socket::sslbuf_ [private] |