5
// Copyright (c) 2005 Voipster / Indrek dot Juhani at voipster dot com
6
// Copyright (c) 2005-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
8
// Distributed under the Boost Software License, Version 1.0. (See accompanying
9
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
12
#ifndef ASIO_SSL_CONTEXT_SERVICE_HPP
13
#define ASIO_SSL_CONTEXT_SERVICE_HPP
15
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
17
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
19
#include "asio/detail/push_options.hpp"
21
#include "asio/detail/push_options.hpp"
23
#include <boost/noncopyable.hpp>
24
#include "asio/detail/pop_options.hpp"
26
#include "asio/error.hpp"
27
#include "asio/io_service.hpp"
28
#include "asio/detail/service_base.hpp"
29
#include "asio/ssl/context_base.hpp"
30
#include "asio/ssl/detail/openssl_context_service.hpp"
35
/// Default service implementation for a context.
37
#if defined(GENERATING_DOCUMENTATION)
38
: public asio::io_service::service
40
: public asio::detail::service_base<context_service>
44
// The type of the platform-specific implementation.
45
typedef detail::openssl_context_service service_impl_type;
48
#if defined(GENERATING_DOCUMENTATION)
49
/// The unique service identifier.
50
static asio::io_service::id id;
53
/// The type of the context.
54
#if defined(GENERATING_DOCUMENTATION)
55
typedef implementation_defined impl_type;
57
typedef service_impl_type::impl_type impl_type;
61
explicit context_service(asio::io_service& io_service)
62
: asio::detail::service_base<context_service>(io_service),
63
service_impl_(asio::use_service<service_impl_type>(io_service))
67
/// Destroy all user-defined handler objects owned by the service.
68
void shutdown_service()
72
/// Return a null context implementation.
73
impl_type null() const
75
return service_impl_.null();
78
/// Create a new context implementation.
79
void create(impl_type& impl, context_base::method m)
81
service_impl_.create(impl, m);
84
/// Destroy a context implementation.
85
void destroy(impl_type& impl)
87
service_impl_.destroy(impl);
90
/// Set options on the context.
91
asio::error_code set_options(impl_type& impl,
92
context_base::options o, asio::error_code& ec)
94
return service_impl_.set_options(impl, o, ec);
97
/// Set peer verification mode.
98
asio::error_code set_verify_mode(impl_type& impl,
99
context_base::verify_mode v, asio::error_code& ec)
101
return service_impl_.set_verify_mode(impl, v, ec);
104
/// Load a certification authority file for performing verification.
105
asio::error_code load_verify_file(impl_type& impl,
106
const std::string& filename, asio::error_code& ec)
108
return service_impl_.load_verify_file(impl, filename, ec);
111
/// Add a directory containing certification authority files to be used for
112
/// performing verification.
113
asio::error_code add_verify_path(impl_type& impl,
114
const std::string& path, asio::error_code& ec)
116
return service_impl_.add_verify_path(impl, path, ec);
119
/// Use a certificate from a file.
120
asio::error_code use_certificate_file(impl_type& impl,
121
const std::string& filename, context_base::file_format format,
122
asio::error_code& ec)
124
return service_impl_.use_certificate_file(impl, filename, format, ec);
127
/// Use a certificate chain from a file.
128
asio::error_code use_certificate_chain_file(impl_type& impl,
129
const std::string& filename, asio::error_code& ec)
131
return service_impl_.use_certificate_chain_file(impl, filename, ec);
134
/// Use a private key from a file.
135
asio::error_code use_private_key_file(impl_type& impl,
136
const std::string& filename, context_base::file_format format,
137
asio::error_code& ec)
139
return service_impl_.use_private_key_file(impl, filename, format, ec);
142
/// Use an RSA private key from a file.
143
asio::error_code use_rsa_private_key_file(impl_type& impl,
144
const std::string& filename, context_base::file_format format,
145
asio::error_code& ec)
147
return service_impl_.use_rsa_private_key_file(impl, filename, format, ec);
150
/// Use the specified file to obtain the temporary Diffie-Hellman parameters.
151
asio::error_code use_tmp_dh_file(impl_type& impl,
152
const std::string& filename, asio::error_code& ec)
154
return service_impl_.use_tmp_dh_file(impl, filename, ec);
157
/// Set the password callback.
158
template <typename PasswordCallback>
159
asio::error_code set_password_callback(impl_type& impl,
160
PasswordCallback callback, asio::error_code& ec)
162
return service_impl_.set_password_callback(impl, callback, ec);
166
// The service that provides the platform-specific implementation.
167
service_impl_type& service_impl_;
173
#include "asio/detail/pop_options.hpp"
175
#endif // ASIO_SSL_CONTEXT_SERVICE_HPP