Encapsulates an openSSL SSL_CTX record. More...
#include <tcpssl.h>
Public Member Functions | |
SSLContext (SSLMode mode) | |
Constructor. More... | |
virtual | ~SSLContext () |
Destructor. | |
void | setOptions (bool verifypeer=false, bool compression=true, bool tlsonly=false) |
Sets default options for all SSL objects created from this context. More... | |
bool | useDefaultVerifyPaths () |
Use the default operating system certificate store for validation. More... | |
bool | setVerifyPaths (const char *cafile=NULL, const char *capath=NULL) |
Use the specified CA certificate or certificate directory. More... | |
bool | setVerifyPaths (string &cafile, string &capath) |
bool | setCertificateAndKey (const char *certfile, const char *keyfile) |
Sets the certificate filename and key filename. More... | |
void | setPrivateKeyPassword (string value) |
Sets the value of the private key password. | |
virtual int | passwordCallback (char *buf, int size, int rwflag) |
Called when a password to decrypt a private key is required. More... | |
Protected Attributes | |
SSL_CTX * | ctx_ |
The openSSL context object. | |
SSLMode | mode_ |
The mode of the context object is passed to SSL objects created from this context. | |
Friends | |
class | SSL |
tcp::SSLContext::SSLContext | ( | SSLMode | mode | ) |
Constructor.
mode | [in] Is this context record for client connections or a server |
Definition at line 242 of file tcpssl.cpp.
|
virtual |
Called when a password to decrypt a private key is required.
Descendant classes may want to override this to provide a more secure means of storing the private key password. The default behavior is to return the value of keypass_.
SSL_CTX_set_default_passwd_cb
for more details Definition at line 382 of file tcpssl.cpp.
bool tcp::SSLContext::setCertificateAndKey | ( | const char * | certfile, |
const char * | keyfile | ||
) |
Sets the certificate filename and key filename.
Sets the certificate and key file for all SSL connections created from this context. This is primarily intended for servers but clients may want to connect to more than one server using the same certificate and key. This default certificate and key set can be overriden for a specific connection using the equivelant method from the SSL class.
certfile | [in] The filename of a certificate chain in PEM (or CRT) format |
keyfile | [in] The filename of a private key in PEM (or CRT) format |
Definition at line 340 of file tcpssl.cpp.
void tcp::SSLContext::setOptions | ( | bool | verifypeer = false , |
bool | compression = true , |
||
bool | tlsonly = false |
||
) |
Sets default options for all SSL objects created from this context.
verifypeer | [in] If true, the server/client will validate the peer certificate |
compression | [in] Set to false to disable SSL compression |
tlsonly | [in] if true, disable the SSLv2 and SSLv3 protocols. This is recommended. |
Definition at line 264 of file tcpssl.cpp.
bool tcp::SSLContext::setVerifyPaths | ( | const char * | cafile = NULL , |
const char * | capath = NULL |
||
) |
Use the specified CA certificate or certificate directory.
Provide one or the other or set both to NULL to use the operating system certificate store
cafile | [in] The filename of a CA certificate chain in PEM (or CRT) format |
capath | [in] The path of a directory containing CA certificates that are considered valid |
Definition at line 315 of file tcpssl.cpp.
|
inline |