|
E-MailRelay
|
A singleton class for initialising the underlying TLS library. More...
#include <gssl.h>
Public Types | |
| typedef void(* | LogFn) (int, const std::string &) |
Public Member Functions | |
| Library (bool active=true, const std::string &library_config=std::string(), LogFn=Library::log, bool verbose=true) | |
| Constructor. More... | |
| ~Library () | |
| Destructor. Cleans up the underlying TLS library. | |
| void | addProfile (const std::string &profile_name, bool is_server_profile, const std::string &key_file=std::string(), const std::string &cert_file=std::string(), const std::string &ca_path=std::string(), const std::string &default_peer_certificate_name=std::string(), const std::string &default_peer_host_name=std::string(), const std::string &profile_config=std::string()) |
| Creates a named Profile object that can be retrieved by profile(). More... | |
| bool | hasProfile (const std::string &profile_name) const |
| Returns true if the named profile has been add()ed. | |
| const Profile & | profile (const std::string &profile_name) const |
| Returns an opaque reference to the named profile. More... | |
| bool | enabled () const |
| Returns true if this is a real TLS library and the constructor's active parameter was set. More... | |
| std::string | id () const |
| Returns the TLS library name and version. | |
| Digester | digester (const std::string &name, const std::string &state=std::string()) const |
| Returns a digester object. | |
Static Public Member Functions | |
| static void | log (int level, const std::string &line) |
| The default logging callback function, where the level is 1 for debug, 2 for info, 3 for warnings, and 4 for errors. More... | |
| static Library * | instance () |
| Returns a pointer to a library object, if any. | |
| static LibraryImpBase & | impstance () |
| Returns a reference to the pimple object when enabled(). More... | |
| static bool | real () |
| Returns true if this is a real TLS library. | |
| static std::string | credit (const std::string &prefix, const std::string &eol, const std::string &eot) |
| Returns a multi-line library credit for all available TLS libraries. | |
| static std::string | ids () |
| Returns a concatenation of all available TLS library names and versions. | |
| static bool | enabledAs (const std::string &profile_name) |
| A static convenience function that returns true if there is an enabled() Library instance() that has the named profile. More... | |
| static G::StringArray | digesters (bool require_state=false) |
| Returns a list of hash function names (such as "MD5") that the TLS library can do, ordered roughly from strongest to weakest. More... | |
A singleton class for initialising the underlying TLS library.
The library is configured with one or more named "profiles", and Protocol objects are constructed with reference to a particular profile. Typical profile names are "server" and "client".
|
explicit |
Constructor.
The 'active' parameter can be set to false as an optimisation if the library is not going to be used; calls to addProfile() will do nothing, calls to hasProfile() will return false, and calls to profile() will throw.
The library-config parameter should be empty by default; the format and interpretation are undefined at this interface.
| void GSsl::Library::addProfile | ( | const std::string & | profile_name, |
| bool | is_server_profile, | ||
| const std::string & | key_file = std::string(), |
||
| const std::string & | cert_file = std::string(), |
||
| const std::string & | ca_path = std::string(), |
||
| const std::string & | default_peer_certificate_name = std::string(), |
||
| const std::string & | default_peer_host_name = std::string(), |
||
| const std::string & | profile_config = std::string() |
||
| ) |
Creates a named Profile object that can be retrieved by profile().
A typical application will have two profiles named "client" and "server". The "is-server-profile" flag indicates whether Protocol::connect() or Protocol::accept() will be used.
The "key-file" and "cert-file" parameters point to a PEM files containing our own key and certificate, and this can be the same file if it contains both. These are required if acting as a server, but if not supplied this method will succeed with the failures occuring in any subsequent server-side session setup.
The "ca-path" parameter points to a file or directory containing a database of CA certificates used for peer certificate verification. If this is "<none>" then a server will not ask its client for a certificate; if it is empty then the peer certificate will be requested, but the server will not require a certificate from the client, and any certificate received will not be not verified; if it is a file system path or "<default>" then a peer certificate will be required and it will be verified against the CA database.
The "default-peer-certificate-name" parameter is used by Protocol objects created from this Profile in cases when the Protocol does not get a more specific peer-certificate-name passed in its constructor.
Similarly the "default-peer-host-name" is used by Protocol objects if they do not get a more specific peer-host-name in their constructor.
The "profile-config" parameter is used for any additional configuration items; the format and interpretation are undefined at this interface.
|
static |
Returns a list of hash function names (such as "MD5") that the TLS library can do, ordered roughly from strongest to weakest.
Returns the empty list if there is no Library instance. If the boolean parameter is true then the returned list is limited to those hash functions that can be initialised with an intermediate state.
| bool GSsl::Library::enabled | ( | ) | const |
|
static |
A static convenience function that returns true if there is an enabled() Library instance() that has the named profile.
|
static |
|
static |
| const GSsl::Profile & GSsl::Library::profile | ( | const std::string & | profile_name | ) | const |
1.8.9.1