#include <ssl.h>
Public Types | |
enum | { ctServer = 1, ctClient = 2, ctMin = ctServer, ctMax = ctClient } |
Connection types handled by a context. More... | |
enum | { cmSSLv2 = 0x1, cmSSLv3 = 0x2, cmTLSv1 = 0x4, cmAny = (cmSSLv2 | cmSSLv2 | cmTLSv1) } |
Connection methods handled by a context. More... | |
enum | { vmVerify = 0x0001, vmFailIfNoPeerCert = 0x0004, vmClientOnce = 0x0008 } |
Verify modes. More... | |
Public Member Functions | |
~SSLContext () | |
Destructor. | |
SSLInfo * | create (TCPClient &client) const |
Creates a new SSLInfo object from this context. | |
void | reject_methods (uint16_t methods) |
Rejects some connection methods. | |
void | verify (uint16_t mode) |
Configures verification. | |
bool | verify_certificate_file (char const *file) |
Loads a list of CA certificates from a file. | |
Events * | events () const |
Returns the events handler. | |
void | events (Events *events) |
Sets the events handler. | |
bool | is_session_caching () const |
Returns whether session caching is enabled. | |
void | set_session_caching (bool value) |
Sets whether session caching is enabled. | |
bool | certificate_chain (char const *file) |
Sets the certificate chain file. | |
bool | private_key_file (char const *file) |
Sets the private key. | |
bool | private_key_check () const |
Ensures the consistency of the private key with the certificate. | |
uint8_t | type () const |
Returns the type of connection handled by this context. | |
uint16_t | methods () const |
Returns an or'ed set of connection methods accepted in this context. | |
char const * | error () const |
Returns the last error of the thread. | |
Static Public Member Functions | |
static void | init () |
Initializes the SSL library. | |
static SSLContext * | factory (uint8_t type, uint16_t methods) |
Instantiates a SSL context if OpenSSL support is available. | |
Friends | |
class | SSLInfo |
Add SSLInfo as a friend. | |
Classes | |
class | Events |
Events callback class. More... |
Like all SSL classes, it is designed to be instantiatable even if there is OpenSSL libraries and header files have not been found on the system. The factory() function in particular allows to build a SSLContext if and only if such support is provided.
anonymous enum |
anonymous enum |
static SSLContext* sockets::SSLContext::factory | ( | uint8_t | type, | |
uint16_t | methods | |||
) | [static] |
Instantiates a SSL context if OpenSSL support is available. This is the only way of creating a SSLContext object.
[in] | type | The connection type for sockets using this context, that might be either ctServer or ctClient. |
[in] | methods | The connection method(s) allowed for sockets using this context, that might be either cmAny, cmSSLv2, cmSSLv3 or cmTLSv1. |
Creates a new SSLInfo object from this context.
void sockets::SSLContext::reject_methods | ( | uint16_t | methods | ) |
Rejects some connection methods. This is supported when the SSL context was created with cmAny as the chosen method.
Note that attempts to disable all remaining methods are ignored.
void sockets::SSLContext::verify | ( | uint16_t | mode | ) |
Configures verification.
Note that the Events::verify() method is called once verification is done, if you set the events handler.
[in] | mode | An or'ed set of vmVerify, vmFailIfNoPeerCert and vmClientOnce. |
bool sockets::SSLContext::verify_certificate_file | ( | char const * | file | ) |
Loads a list of CA certificates for the certificate verification process from a file.
[in] | file | The file to load the certificates from, in PEM format. |
void sockets::SSLContext::events | ( | Events * | events | ) | [inline] |
Sets the events handler. The methods of this object are called when the corresponding event happens on the context and the connections initiated by the context.
bool sockets::SSLContext::is_session_caching | ( | ) | const |
Returns whether session caching is enabled. By default, it is enabled for servers but not for clients.
bool sockets::SSLContext::certificate_chain | ( | char const * | file | ) |
Sets the certificate chain file.
[in] | file | The certificate chain file, in PEM format |
bool sockets::SSLContext::private_key_file | ( | char const * | file | ) |
Sets the private key.
[in] | file | The certificate key file, in PEM format. |