Boost C++ Libraries Home Libraries People FAQ More

Home | Reference | Tutorial | Examples | Design
Reference Index | Class Hierarchy | Class Index | Member Index

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

Inherits boost::asio::ssl::context_base.

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

Inheritance graph
List of all members.

Detailed Description

template<typename Service>
class boost::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.
typedef int options
 Bitmask type for SSL options.
typedef int verify_mode
 Bitmask type for peer verification.
 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.
 asn1
 ASN.1 file.
 pem
 PEM file.
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...

Public Member Functions

 basic_context (boost::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.
template<typename Error_Handler>
void set_options (options o, Error_Handler error_handler)
 Set options on the context.
void set_verify_mode (verify_mode v)
 Set the peer verification mode.
template<typename Error_Handler>
void set_verify_mode (verify_mode v, Error_Handler error_handler)
 Set the peer verification mode.
void load_verify_file (const std::string &filename)
 Load a certification authority file for performing verification.
template<typename Error_Handler>
void load_verify_file (const std::string &filename, Error_Handler error_handler)
 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.
template<typename Error_Handler>
void add_verify_path (const std::string &path, Error_Handler error_handler)
 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.
template<typename Error_Handler>
void use_certificate_file (const std::string &filename, file_format format, Error_Handler error_handler)
 Use a certificate from a file.
void use_certificate_chain_file (const std::string &filename)
 Use a certificate chain from a file.
template<typename Error_Handler>
void use_certificate_chain_file (const std::string &filename, Error_Handler error_handler)
 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.
template<typename Error_Handler>
void use_private_key_file (const std::string &filename, file_format format, Error_Handler error_handler)
 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.
template<typename Error_Handler>
void use_rsa_private_key_file (const std::string &filename, file_format format, Error_Handler error_handler)
 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.
template<typename Error_Handler>
void use_tmp_dh_file (const std::string &filename, Error_Handler error_handler)
 Use the specified file to obtain the temporary Diffie-Hellman parameters.

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 boost::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 boost::asio::ssl::basic_context< Service >::impl_type

The native implementation type of the locking dispatcher.

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

Bitmask type for SSL options.

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

Bitmask type for peer verification.


Member Enumeration Documentation

enum boost::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 boost::asio::ssl::context_base::file_format [inherited]

File format types.

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


Constructor & Destructor Documentation

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

Constructor.

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

Destructor.


Member Function Documentation

template<typename Service>
impl_type boost::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 boost::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:
boost::asio::error Thrown on failure.

template<typename Service>
template<typename Error_Handler>
void boost::asio::ssl::basic_context< Service >::set_options ( options  o,
Error_Handler  error_handler 
)

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.
error_handler A handler to be called when the operation completes, to indicate whether or not an error has occurred. Copies will be made of the handler as required. The function signature of the handler must be:
 void error_handler(
   const boost::asio::error& error // Result of operation
 ); 

template<typename Service>
void boost::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:
boost::asio::error Thrown on failure.

template<typename Service>
template<typename Error_Handler>
void boost::asio::ssl::basic_context< Service >::set_verify_mode ( verify_mode  v,
Error_Handler  error_handler 
)

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.
error_handler A handler to be called when the operation completes, to indicate whether or not an error has occurred. Copies will be made of the handler as required. The function signature of the handler must be:
 void error_handler(
   const boost::asio::error& error // Result of operation
 ); 

template<typename Service>
void boost::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:
boost::asio::error Thrown on failure.

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

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.
error_handler A handler to be called when the operation completes, to indicate whether or not an error has occurred. Copies will be made of the handler as required. The function signature of the handler must be:
 void error_handler(
   const boost::asio::error& error // Result of operation
 ); 

template<typename Service>
void boost::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:
boost::asio::error Thrown on failure.

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

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.
error_handler A handler to be called when the operation completes, to indicate whether or not an error has occurred. Copies will be made of the handler as required. The function signature of the handler must be:
 void error_handler(
   const boost::asio::error& error // Result of operation
 ); 

template<typename Service>
void boost::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:
boost::asio::error Thrown on failure.

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

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).
error_handler A handler to be called when the operation completes, to indicate whether or not an error has occurred. Copies will be made of the handler as required. The function signature of the handler must be:
 void error_handler(
   const boost::asio::error& error // Result of operation
 ); 

template<typename Service>
void boost::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:
boost::asio::error Thrown on failure.

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

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.
error_handler A handler to be called when the operation completes, to indicate whether or not an error has occurred. Copies will be made of the handler as required. The function signature of the handler must be:
 void error_handler(
   const boost::asio::error& error // Result of operation
 ); 

template<typename Service>
void boost::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:
boost::asio::error Thrown on failure.

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

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).
error_handler A handler to be called when the operation completes, to indicate whether or not an error has occurred. Copies will be made of the handler as required. The function signature of the handler must be:
 void error_handler(
   const boost::asio::error& error // Result of operation
 ); 

template<typename Service>
void boost::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:
boost::asio::error Thrown on failure.

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

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).
error_handler A handler to be called when the operation completes, to indicate whether or not an error has occurred. Copies will be made of the handler as required. The function signature of the handler must be:
 void error_handler(
   const boost::asio::error& error // Result of operation
 ); 

template<typename Service>
void boost::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:
boost::asio::error Thrown on failure.

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

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.
error_handler A handler to be called when the operation completes, to indicate whether or not an error has occurred. Copies will be made of the handler as required. The function signature of the handler must be:
 void error_handler(
   const boost::asio::error& error // Result of operation
 ); 


Member Data Documentation

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

The backend service implementation.

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

The underlying native implementation.

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

Implement various bug workarounds.

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

Always create a new key when using tmp_dh parameters.

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

Disable SSL v2.

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

Disable SSL v3.

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

Disable TLS v1.

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

No verification.

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

Verify the peer.

const int boost::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 boost::asio::ssl::context_base::verify_client_once = implementation_defined [static, inherited]

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

Copyright © 2003 - 2006 Christopher M. Kohlhoff


Home | Reference | Tutorial | Examples | Design