#include <SSL_Context.h>
Public Types | |
enum | { INVALID_METHOD = -1, SSLv2_client = 1, SSLv2_server, SSLv2, SSLv3_client, SSLv3_server, SSLv3, SSLv23_client, SSLv23_server, SSLv23, TLSv1_client, TLSv1_server, TLSv1 } |
typedef ACE_SYNCH_MUTEX | lock_type |
Public Member Functions | |
ACE_SSL_Context (void) | |
Constructor. | |
~ACE_SSL_Context (void) | |
Destructor. | |
int | set_mode (int mode=ACE_SSL_Context::SSLv23) |
int | get_mode (void) const |
SSL_CTX * | context (void) |
Get the SSL context. | |
int | private_key_type (void) const |
Get the file name and file format used for the private key. | |
const char * | private_key_file_name (void) const |
int | private_key (const char *file_name, int type=SSL_FILETYPE_PEM) |
Set the private key file. | |
int | verify_private_key (void) |
Verify that the private key is valid. | |
int | certificate_type (void) const |
Get the file name and file format used for the certificate file. | |
const char * | certificate_file_name (void) const |
int | certificate (const char *file_name, int type=SSL_FILETYPE_PEM) |
Set the certificate file. | |
int | certificate (X509 *cert) |
Load certificate from memory rather than a file. | |
int | load_trusted_ca (const char *ca_file=0, const char *ca_dir=0, bool use_env_defaults=true) |
int | have_trusted_ca (void) const |
void | set_verify_peer (int strict=0, int once=1, int depth=0) |
void | default_verify_mode (int mode) |
int | default_verify_mode (void) const |
Diffie-Hellman (DH) Parameters | |
When using DSS-based certificates, Diffie-Hellman keys need to be exchanged. These must be provided in the form of DH key generation parameters loaded in, or as fixed keys hardcoded into the code itself. ACE_SSL supports loaded parameters. | |
int | dh_params (const char *file_name, int type=SSL_FILETYPE_PEM) |
const char * | dh_params_file_name () const |
int | dh_params_file_type () const |
Static Public Member Functions | |
static ACE_SSL_Context * | instance (void) |
static void | report_error (unsigned long error_code) |
Print SSL error corresponding to the given error code. | |
static void | report_error (void) |
Print the last SSL error for the current thread. | |
OpenSSL Random Number Generator Seed Related Methods | |
These are methods that can be used to seed OpenSSL's pseudo-random number generator. These methods can be called more than once. | |
static int | random_seed (const char *seed) |
static int | egd_file (const char *socket_file) |
static int | seed_file (const char *seed_file, long bytes=-1) |
Private Member Functions | |
void | check_context (void) |
Verify if the context has been initialized or not. | |
void | ssl_library_init () |
@ More to document | |
void | ssl_library_fini () |
ACE_SSL_Context (const ACE_SSL_Context &) | |
ACE_SSL_Context & | operator= (const ACE_SSL_Context &) |
Private Attributes | |
SSL_CTX * | context_ |
The SSL_CTX structure. | |
int | mode_ |
Cache the mode so we can answer fast. | |
ACE_SSL_Data_File | private_key_ |
The private key, certificate, and Diffie-Hellman paramters files. | |
ACE_SSL_Data_File | certificate_ |
ACE_SSL_Data_File | dh_params_ |
int | default_verify_mode_ |
The default verify mode. | |
int | have_ca_ |
count of successful CA load attempts | |
Static Private Attributes | |
static lock_type * | locks_ |
This class provides a wrapper for the SSL_CTX data structure. Since most applications have a single SSL_CTX structure, this class can be used as a singleton.
typedef ACE_SYNCH_MUTEX ACE_SSL_Context::lock_type |
anonymous enum |
ACE_SSL_Context::ACE_SSL_Context | ( | void | ) |
Constructor.
ACE_SSL_Context::~ACE_SSL_Context | ( | void | ) |
Destructor.
ACE_SSL_Context::ACE_SSL_Context | ( | const ACE_SSL_Context & | ) | [private] |
ACE_SSL_Context * ACE_SSL_Context::instance | ( | void | ) | [static] |
The Singleton context, the SSL components use the singleton if nothing else is available.
int ACE_SSL_Context::set_mode | ( | int | mode = ACE_SSL_Context::SSLv23 |
) |
Set the CTX mode. The mode can be set only once, afterwards the function has no effect and returns -1. Once the mode is set the underlying SSL_CTX is initialized and the class can be used. If the mode is not set, then the class automatically initializes itself to the default mode.
ACE_INLINE int ACE_SSL_Context::get_mode | ( | void | ) | const |
ACE_INLINE SSL_CTX * ACE_SSL_Context::context | ( | void | ) |
Get the SSL context.
ACE_INLINE int ACE_SSL_Context::private_key_type | ( | void | ) | const |
Get the file name and file format used for the private key.
ACE_INLINE const char * ACE_SSL_Context::private_key_file_name | ( | void | ) | const |
int ACE_SSL_Context::private_key | ( | const char * | file_name, | |
int | type = SSL_FILETYPE_PEM | |||
) |
Set the private key file.
int ACE_SSL_Context::verify_private_key | ( | void | ) |
Verify that the private key is valid.
ACE_INLINE int ACE_SSL_Context::certificate_type | ( | void | ) | const |
Get the file name and file format used for the certificate file.
ACE_INLINE const char * ACE_SSL_Context::certificate_file_name | ( | void | ) | const |
int ACE_SSL_Context::certificate | ( | const char * | file_name, | |
int | type = SSL_FILETYPE_PEM | |||
) |
Set the certificate file.
int ACE_SSL_Context::certificate | ( | X509 * | cert | ) |
Load certificate from memory rather than a file.
int ACE_SSL_Context::load_trusted_ca | ( | const char * | ca_file = 0 , |
|
const char * | ca_dir = 0 , |
|||
bool | use_env_defaults = true | |||
) |
Load the location of the trusted certification authority certificates. Note that CA certificates are stored in PEM format as a sequence of certificates in ca_file or as a set of individual certificates in ca_dir (or both).
Note this method is called by set_mode() to load the default environment settings for ca_file and ca_dir, if any. This allows for automatic service configuration (and backward compatibility with previous versions).
Note that the underlying SSL function will add valid file and directory names to the load location lists maintained as part of the SSL_CTX table. It therefore doesn't make sense to keep a copy of the file and path name of the most recently added ca_file or ca_path.
[in] | ca_file | CA file pathname. Passed to SSL_CTX_load_verify_locations() if not 0. If 0, behavior depends on the value of use_env_defaults. |
[in] | ca_dir | CA directory pathname. Passed to SSL_CTX_load_verify_locations() if not 0. If 0, behavior depends on the value of use_env_defaults. |
[in] | use_env_defaults | If false, the specified ca_file argument is passed to SSL_CTX_load_verify_locations() , regardless of its value. If true (the default), additional defaults can be applied to either ca_file, ca_dir, or both. The following additional defaults are applied when the ca_file argument is 0:
|
ACE_INLINE int ACE_SSL_Context::have_trusted_ca | ( | void | ) | const |
Test whether any CA locations have been successfully loaded and return the number of successful attempts.
>0 | The number of successful CA load attempts. | |
0 | If all CA load attempts have failed. |
void ACE_SSL_Context::set_verify_peer | ( | int | strict = 0 , |
|
int | once = 1 , |
|||
int | depth = 0 | |||
) |
Note for verification to work correctly there should be a valid CA name list set using load_trusted_ca().
OpenSSL documentation ... set_verify_depth(3) ...
ACE_INLINE void ACE_SSL_Context::default_verify_mode | ( | int | mode | ) |
TODO: a implementation that will lookup the CTX table for the list of files and paths etc. Query the location of trusted certification authority certificates. Set and query the default verify mode for this context, it is inherited by all the ACE_SSL objects created using the context. It can be overriden on a per-ACE_SSL object.
ACE_INLINE int ACE_SSL_Context::default_verify_mode | ( | void | ) | const |
int ACE_SSL_Context::random_seed | ( | const char * | seed | ) | [static] |
Seed the underlying random number generator. This value should have at least 128 bits of entropy.
int ACE_SSL_Context::egd_file | ( | const char * | socket_file | ) | [static] |
Set the Entropy Gathering Daemon (EGD) UNIX domain socket file to read random seed values from.
int ACE_SSL_Context::seed_file | ( | const char * | seed_file, | |
long | bytes = -1 | |||
) | [static] |
Set the file that contains the random seed value state, and the amount of bytes to read. "-1" bytes causes the entire file to be read.
void ACE_SSL_Context::report_error | ( | unsigned long | error_code | ) | [static] |
Print SSL error corresponding to the given error code.
void ACE_SSL_Context::report_error | ( | void | ) | [static] |
Print the last SSL error for the current thread.
int ACE_SSL_Context::dh_params | ( | const char * | file_name, | |
int | type = SSL_FILETYPE_PEM | |||
) |
Load Diffie-Hellman parameters from file_name. The specified file can be a standalone file containing only DH parameters (e.g., as created by openssl dhparam
), or it can be a certificate which has a PEM-encoded set of DH params concatenated on to i.
ACE_INLINE const char * ACE_SSL_Context::dh_params_file_name | ( | void | ) | const |
Load Diffie-Hellman parameters from file_name. The specified file can be a standalone file containing only DH parameters (e.g., as created by openssl dhparam
), or it can be a certificate which has a PEM-encoded set of DH params concatenated on to i.
ACE_INLINE int ACE_SSL_Context::dh_params_file_type | ( | void | ) | const |
Load Diffie-Hellman parameters from file_name. The specified file can be a standalone file containing only DH parameters (e.g., as created by openssl dhparam
), or it can be a certificate which has a PEM-encoded set of DH params concatenated on to i.
ACE_INLINE void ACE_SSL_Context::check_context | ( | void | ) | [private] |
Verify if the context has been initialized or not.
void ACE_SSL_Context::ssl_library_init | ( | void | ) | [private] |
@ More to document
void ACE_SSL_Context::ssl_library_fini | ( | void | ) | [private] |
ACE_SSL_Context& ACE_SSL_Context::operator= | ( | const ACE_SSL_Context & | ) | [private] |
SSL_CTX* ACE_SSL_Context::context_ [private] |
The SSL_CTX structure.
int ACE_SSL_Context::mode_ [private] |
Cache the mode so we can answer fast.
The private key, certificate, and Diffie-Hellman paramters files.
ACE_SSL_Data_File ACE_SSL_Context::dh_params_ [private] |
int ACE_SSL_Context::default_verify_mode_ [private] |
The default verify mode.
int ACE_SSL_Context::have_ca_ [private] |
count of successful CA load attempts
lock_type* ACE_SSL_Context::locks_ [static, private] |
Array of mutexes used internally by OpenSSL when the SSL application is multithreaded.