asio 0.3.8rc3 Home | Reference | Tutorial | Examples | Design
Reference Class Hierarchy | Class Index | Member Index

asio::ssl::basic_context< Service > Class Template Reference

Inheritance diagram for asio::ssl::basic_context< Service >:

Inheritance graph

List of all members.


Detailed Description

template<typename Service>
class asio::ssl::basic_context< Service >

SSL context.

Public Types

typedef Service service_type
 The type of the service that will be used to provide context operations.
typedef service_type::impl_type impl_type
 The native implementation type of the locking dispatcher.
enum  method {
  sslv2,
  sslv2_client,
  sslv2_server,
  sslv3,
  sslv3_client,
  sslv3_server,
  tlsv1,
  tlsv1_client,
  tlsv1_server,
  sslv23,
  sslv23_client,
  sslv23_server
}
 Different methods supported by a context. More...
enum  file_format {
  asn1,
  pem
}
 File format types. More...
enum  password_purpose {
  for_reading,
  for_writing
}
 Purpose of PEM password. More...
typedef int options
 Bitmask type for SSL options.
typedef int verify_mode
 Bitmask type for peer verification.

Public Member Functions

 basic_context (asio::io_service &io_service, method m)
 Constructor.
 ~basic_context ()
 Destructor.
impl_type impl ()
 Get the underlying implementation in the native type.
void set_options (options o)
 Set options on the context.
asio::error_code set_options (options o, asio::error_code &ec)
 Set options on the context.
void set_verify_mode (verify_mode v)
 Set the peer verification mode.
asio::error_code set_verify_mode (verify_mode v, asio::error_code &ec)
 Set the peer verification mode.
void load_verify_file (const std::string &filename)
 Load a certification authority file for performing verification.
asio::error_code load_verify_file (const std::string &filename, asio::error_code &ec)
 Load a certification authority file for performing verification.
void add_verify_path (const std::string &path)
 Add a directory containing certificate authority files to be used for performing verification.
asio::error_code add_verify_path (const std::string &path, asio::error_code &ec)
 Add a directory containing certificate authority files to be used for performing verification.
void use_certificate_file (const std::string &filename, file_format format)
 Use a certificate from a file.
asio::error_code use_certificate_file (const std::string &filename, file_format format, asio::error_code &ec)
 Use a certificate from a file.
void use_certificate_chain_file (const std::string &filename)
 Use a certificate chain from a file.
asio::error_code use_certificate_chain_file (const std::string &filename, asio::error_code &ec)
 Use a certificate chain from a file.
void use_private_key_file (const std::string &filename, file_format format)
 Use a private key from a file.
asio::error_code use_private_key_file (const std::string &filename, file_format format, asio::error_code &ec)
 Use a private key from a file.
void use_rsa_private_key_file (const std::string &filename, file_format format)
 Use an RSA private key from a file.
asio::error_code use_rsa_private_key_file (const std::string &filename, file_format format, asio::error_code &ec)
 Use an RSA private key from a file.
void use_tmp_dh_file (const std::string &filename)
 Use the specified file to obtain the temporary Diffie-Hellman parameters.
asio::error_code use_tmp_dh_file (const std::string &filename, asio::error_code &ec)
 Use the specified file to obtain the temporary Diffie-Hellman parameters.
template<typename PasswordCallback>
void set_password_callback (PasswordCallback callback)
 Set the password callback.
template<typename PasswordCallback>
asio::error_code set_password_callback (PasswordCallback callback, asio::error_code &ec)
 Set the password callback.

Static Public Attributes

static const int default_workarounds = implementation_defined
 Implement various bug workarounds.
static const int single_dh_use = implementation_defined
 Always create a new key when using tmp_dh parameters.
static const int no_sslv2 = implementation_defined
 Disable SSL v2.
static const int no_sslv3 = implementation_defined
 Disable SSL v3.
static const int no_tlsv1 = implementation_defined
 Disable TLS v1.
static const int verify_none = implementation_defined
 No verification.
static const int verify_peer = implementation_defined
 Verify the peer.
static const int verify_fail_if_no_peer_cert = implementation_defined
 Fail verification if the peer has no certificate. Ignored unless verify_peer is set.
static const int verify_client_once = implementation_defined
 Do not request client certificate on renegotiation. Ignored unless verify_peer is set.

Private Attributes

service_typeservice_
 The backend service implementation.
impl_type impl_
 The underlying native implementation.

Member Typedef Documentation

template<typename Service>
typedef Service asio::ssl::basic_context< Service >::service_type

The type of the service that will be used to provide context operations.

template<typename Service>
typedef service_type::impl_type asio::ssl::basic_context< Service >::impl_type

The native implementation type of the locking dispatcher.

typedef int asio::ssl::context_base::options [inherited]

Bitmask type for SSL options.

typedef int asio::ssl::context_base::verify_mode [inherited]

Bitmask type for peer verification.


Member Enumeration Documentation

enum asio::ssl::context_base::method [inherited]

Different methods supported by a context.

Enumerator:
sslv2  Generic SSL version 2.
sslv2_client  SSL version 2 client.
sslv2_server  SSL version 2 server.
sslv3  Generic SSL version 3.
sslv3_client  SSL version 3 client.
sslv3_server  SSL version 3 server.
tlsv1  Generic TLS version 1.
tlsv1_client  TLS version 1 client.
tlsv1_server  TLS version 1 server.
sslv23  Generic SSL/TLS.
sslv23_client  SSL/TLS client.
sslv23_server  SSL/TLS server.

enum asio::ssl::context_base::file_format [inherited]

File format types.

Enumerator:
asn1  ASN.1 file.
pem  PEM file.

enum asio::ssl::context_base::password_purpose [inherited]

Purpose of PEM password.

Enumerator:
for_reading  The password is needed for reading/decryption.
for_writing  The password is needed for writing/encryption.


Constructor & Destructor Documentation

template<typename Service>
asio::ssl::basic_context< Service >::basic_context ( asio::io_service io_service,
method  m 
)

Constructor.

template<typename Service>
asio::ssl::basic_context< Service >::~basic_context (  ) 

Destructor.


Member Function Documentation

template<typename Service>
impl_type asio::ssl::basic_context< Service >::impl (  ) 

Get the underlying implementation in the native type.

This function may be used to obtain the underlying implementation of the context. This is intended to allow access to context functionality that is not otherwise provided.

template<typename Service>
void asio::ssl::basic_context< Service >::set_options ( options  o  ) 

Set options on the context.

This function may be used to configure the SSL options used by the context.

Parameters:
o A bitmask of options. The available option values are defined in the context_base class. The options are bitwise-ored with any existing value for the options.
Exceptions:
asio::system_error Thrown on failure.

template<typename Service>
asio::error_code asio::ssl::basic_context< Service >::set_options ( options  o,
asio::error_code ec 
)

Set options on the context.

This function may be used to configure the SSL options used by the context.

Parameters:
o A bitmask of options. The available option values are defined in the context_base class. The options are bitwise-ored with any existing value for the options.
ec Set to indicate what error occurred, if any.

template<typename Service>
void asio::ssl::basic_context< Service >::set_verify_mode ( verify_mode  v  ) 

Set the peer verification mode.

This function may be used to configure the peer verification mode used by the context.

Parameters:
v A bitmask of peer verification modes. The available verify_mode values are defined in the context_base class.
Exceptions:
asio::system_error Thrown on failure.

template<typename Service>
asio::error_code asio::ssl::basic_context< Service >::set_verify_mode ( verify_mode  v,
asio::error_code ec 
)

Set the peer verification mode.

This function may be used to configure the peer verification mode used by the context.

Parameters:
v A bitmask of peer verification modes. The available verify_mode values are defined in the context_base class.
ec Set to indicate what error occurred, if any.

template<typename Service>
void asio::ssl::basic_context< Service >::load_verify_file ( const std::string &  filename  ) 

Load a certification authority file for performing verification.

This function is used to load one or more trusted certification authorities from a file.

Parameters:
filename The name of a file containing certification authority certificates in PEM format.
Exceptions:
asio::system_error Thrown on failure.

template<typename Service>
asio::error_code asio::ssl::basic_context< Service >::load_verify_file ( const std::string &  filename,
asio::error_code ec 
)

Load a certification authority file for performing verification.

This function is used to load the certificates for one or more trusted certification authorities from a file.

Parameters:
filename The name of a file containing certification authority certificates in PEM format.
ec Set to indicate what error occurred, if any.

template<typename Service>
void asio::ssl::basic_context< Service >::add_verify_path ( const std::string &  path  ) 

Add a directory containing certificate authority files to be used for performing verification.

This function is used to specify the name of a directory containing certification authority certificates. Each file in the directory must contain a single certificate. The files must be named using the subject name's hash and an extension of ".0".

Parameters:
path The name of a directory containing the certificates.
Exceptions:
asio::system_error Thrown on failure.

template<typename Service>
asio::error_code asio::ssl::basic_context< Service >::add_verify_path ( const std::string &  path,
asio::error_code ec 
)

Add a directory containing certificate authority files to be used for performing verification.

This function is used to specify the name of a directory containing certification authority certificates. Each file in the directory must contain a single certificate. The files must be named using the subject name's hash and an extension of ".0".

Parameters:
path The name of a directory containing the certificates.
ec Set to indicate what error occurred, if any.

template<typename Service>
void asio::ssl::basic_context< Service >::use_certificate_file ( const std::string &  filename,
file_format  format 
)

Use a certificate from a file.

This function is used to load a certificate into the context from a file.

Parameters:
filename The name of the file containing the certificate.
format The file format (ASN.1 or PEM).
Exceptions:
asio::system_error Thrown on failure.

template<typename Service>
asio::error_code asio::ssl::basic_context< Service >::use_certificate_file ( const std::string &  filename,
file_format  format,
asio::error_code ec 
)

Use a certificate from a file.

This function is used to load a certificate into the context from a file.

Parameters:
filename The name of the file containing the certificate.
format The file format (ASN.1 or PEM).
ec Set to indicate what error occurred, if any.

template<typename Service>
void asio::ssl::basic_context< Service >::use_certificate_chain_file ( const std::string &  filename  ) 

Use a certificate chain from a file.

This function is used to load a certificate chain into the context from a file.

Parameters:
filename The name of the file containing the certificate. The file must use the PEM format.
Exceptions:
asio::system_error Thrown on failure.

template<typename Service>
asio::error_code asio::ssl::basic_context< Service >::use_certificate_chain_file ( const std::string &  filename,
asio::error_code ec 
)

Use a certificate chain from a file.

This function is used to load a certificate chain into the context from a file.

Parameters:
filename The name of the file containing the certificate. The file must use the PEM format.
ec Set to indicate what error occurred, if any.

template<typename Service>
void asio::ssl::basic_context< Service >::use_private_key_file ( const std::string &  filename,
file_format  format 
)

Use a private key from a file.

This function is used to load a private key into the context from a file.

Parameters:
filename The name of the file containing the private key.
format The file format (ASN.1 or PEM).
Exceptions:
asio::system_error Thrown on failure.

template<typename Service>
asio::error_code asio::ssl::basic_context< Service >::use_private_key_file ( const std::string &  filename,
file_format  format,
asio::error_code ec 
)

Use a private key from a file.

This function is used to load a private key into the context from a file.

Parameters:
filename The name of the file containing the private key.
format The file format (ASN.1 or PEM).
ec Set to indicate what error occurred, if any.

template<typename Service>
void asio::ssl::basic_context< Service >::use_rsa_private_key_file ( const std::string &  filename,
file_format  format 
)

Use an RSA private key from a file.

This function is used to load an RSA private key into the context from a file.

Parameters:
filename The name of the file containing the RSA private key.
format The file format (ASN.1 or PEM).
Exceptions:
asio::system_error Thrown on failure.

template<typename Service>
asio::error_code asio::ssl::basic_context< Service >::use_rsa_private_key_file ( const std::string &  filename,
file_format  format,
asio::error_code ec 
)

Use an RSA private key from a file.

This function is used to load an RSA private key into the context from a file.

Parameters:
filename The name of the file containing the RSA private key.
format The file format (ASN.1 or PEM).
ec Set to indicate what error occurred, if any.

template<typename Service>
void asio::ssl::basic_context< Service >::use_tmp_dh_file ( const std::string &  filename  ) 

Use the specified file to obtain the temporary Diffie-Hellman parameters.

This function is used to load Diffie-Hellman parameters into the context from a file.

Parameters:
filename The name of the file containing the Diffie-Hellman parameters. The file must use the PEM format.
Exceptions:
asio::system_error Thrown on failure.

template<typename Service>
asio::error_code asio::ssl::basic_context< Service >::use_tmp_dh_file ( const std::string &  filename,
asio::error_code ec 
)

Use the specified file to obtain the temporary Diffie-Hellman parameters.

This function is used to load Diffie-Hellman parameters into the context from a file.

Parameters:
filename The name of the file containing the Diffie-Hellman parameters. The file must use the PEM format.
ec Set to indicate what error occurred, if any.

template<typename Service>
template<typename PasswordCallback>
void asio::ssl::basic_context< Service >::set_password_callback ( PasswordCallback  callback  ) 

Set the password callback.

This function is used to specify a callback function to obtain password information about an encrypted key in PEM format.

Parameters:
callback The function object to be used for obtaining the password. The function signature of the handler must be:
 std::string password_callback(
   std::size_t max_length,  // The maximum size for a password.
   password_purpose purpose // Whether password is for reading or writing.
 ); 
The return value of the callback is a string containing the password.
Exceptions:
asio::system_error Thrown on failure.

template<typename Service>
template<typename PasswordCallback>
asio::error_code asio::ssl::basic_context< Service >::set_password_callback ( PasswordCallback  callback,
asio::error_code ec 
)

Set the password callback.

This function is used to specify a callback function to obtain password information about an encrypted key in PEM format.

Parameters:
callback The function object to be used for obtaining the password. The function signature of the handler must be:
 std::string password_callback(
   std::size_t max_length,  // The maximum size for a password.
   password_purpose purpose // Whether password is for reading or writing.
 ); 
The return value of the callback is a string containing the password.
ec Set to indicate what error occurred, if any.


Member Data Documentation

template<typename Service>
service_type& asio::ssl::basic_context< Service >::service_ [private]

The backend service implementation.

template<typename Service>
impl_type asio::ssl::basic_context< Service >::impl_ [private]

The underlying native implementation.

const int asio::ssl::context_base::default_workarounds = implementation_defined [static, inherited]

Implement various bug workarounds.

const int asio::ssl::context_base::single_dh_use = implementation_defined [static, inherited]

Always create a new key when using tmp_dh parameters.

const int asio::ssl::context_base::no_sslv2 = implementation_defined [static, inherited]

Disable SSL v2.

const int asio::ssl::context_base::no_sslv3 = implementation_defined [static, inherited]

Disable SSL v3.

const int asio::ssl::context_base::no_tlsv1 = implementation_defined [static, inherited]

Disable TLS v1.

const int asio::ssl::context_base::verify_none = implementation_defined [static, inherited]

No verification.

const int asio::ssl::context_base::verify_peer = implementation_defined [static, inherited]

Verify the peer.

const int asio::ssl::context_base::verify_fail_if_no_peer_cert = implementation_defined [static, inherited]

Fail verification if the peer has no certificate. Ignored unless verify_peer is set.

const int asio::ssl::context_base::verify_client_once = implementation_defined [static, inherited]

Do not request client certificate on renegotiation. Ignored unless verify_peer is set.

asio 0.3.8rc3 Home | Reference | Tutorial | Examples | Design