2 // ssl/old/context_service.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2005 Voipster / Indrek dot Juhani at voipster dot com
6 // Copyright (c) 2005-2016 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 BOOST_ASIO_SSL_OLD_CONTEXT_SERVICE_HPP
13 #define BOOST_ASIO_SSL_OLD_CONTEXT_SERVICE_HPP
15 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
17 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
19 #include <boost/asio/detail/config.hpp>
21 #include <boost/noncopyable.hpp>
22 #include <boost/asio/error.hpp>
23 #include <boost/asio/io_service.hpp>
24 #include <boost/asio/ssl/context_base.hpp>
25 #include <boost/asio/ssl/old/detail/openssl_context_service.hpp>
27 #include <boost/asio/detail/push_options.hpp>
34 /// Default service implementation for a context.
36 #if defined(GENERATING_DOCUMENTATION)
37 : public boost::asio::io_service::service
39 : public boost::asio::detail::service_base<context_service>
43 // The type of the platform-specific implementation.
44 typedef old::detail::openssl_context_service service_impl_type;
47 #if defined(GENERATING_DOCUMENTATION)
48 /// The unique service identifier.
49 static boost::asio::io_service::id id;
52 /// The type of the context.
53 #if defined(GENERATING_DOCUMENTATION)
54 typedef implementation_defined impl_type;
56 typedef service_impl_type::impl_type impl_type;
60 explicit context_service(boost::asio::io_service& io_service)
61 : boost::asio::detail::service_base<context_service>(io_service),
62 service_impl_(boost::asio::use_service<service_impl_type>(io_service))
66 /// Return a null context implementation.
67 impl_type null() const
69 return service_impl_.null();
72 /// Create a new context implementation.
73 void create(impl_type& impl, context_base::method m)
75 service_impl_.create(impl, m);
78 /// Destroy a context implementation.
79 void destroy(impl_type& impl)
81 service_impl_.destroy(impl);
84 /// Set options on the context.
85 boost::system::error_code set_options(impl_type& impl,
86 context_base::options o, boost::system::error_code& ec)
88 return service_impl_.set_options(impl, o, ec);
91 /// Set peer verification mode.
92 boost::system::error_code set_verify_mode(impl_type& impl,
93 context_base::verify_mode v, boost::system::error_code& ec)
95 return service_impl_.set_verify_mode(impl, v, ec);
98 /// Load a certification authority file for performing verification.
99 boost::system::error_code load_verify_file(impl_type& impl,
100 const std::string& filename, boost::system::error_code& ec)
102 return service_impl_.load_verify_file(impl, filename, ec);
105 /// Add a directory containing certification authority files to be used for
106 /// performing verification.
107 boost::system::error_code add_verify_path(impl_type& impl,
108 const std::string& path, boost::system::error_code& ec)
110 return service_impl_.add_verify_path(impl, path, ec);
113 /// Use a certificate from a file.
114 boost::system::error_code use_certificate_file(impl_type& impl,
115 const std::string& filename, context_base::file_format format,
116 boost::system::error_code& ec)
118 return service_impl_.use_certificate_file(impl, filename, format, ec);
121 /// Use a certificate chain from a file.
122 boost::system::error_code use_certificate_chain_file(impl_type& impl,
123 const std::string& filename, boost::system::error_code& ec)
125 return service_impl_.use_certificate_chain_file(impl, filename, ec);
128 /// Use a private key from a file.
129 boost::system::error_code use_private_key_file(impl_type& impl,
130 const std::string& filename, context_base::file_format format,
131 boost::system::error_code& ec)
133 return service_impl_.use_private_key_file(impl, filename, format, ec);
136 /// Use an RSA private key from a file.
137 boost::system::error_code use_rsa_private_key_file(impl_type& impl,
138 const std::string& filename, context_base::file_format format,
139 boost::system::error_code& ec)
141 return service_impl_.use_rsa_private_key_file(impl, filename, format, ec);
144 /// Use the specified file to obtain the temporary Diffie-Hellman parameters.
145 boost::system::error_code use_tmp_dh_file(impl_type& impl,
146 const std::string& filename, boost::system::error_code& ec)
148 return service_impl_.use_tmp_dh_file(impl, filename, ec);
151 /// Set the password callback.
152 template <typename PasswordCallback>
153 boost::system::error_code set_password_callback(impl_type& impl,
154 PasswordCallback callback, boost::system::error_code& ec)
156 return service_impl_.set_password_callback(impl, callback, ec);
160 // Destroy all user-defined handler objects owned by the service.
161 void shutdown_service()
165 // The service that provides the platform-specific implementation.
166 service_impl_type& service_impl_;
174 #include <boost/asio/detail/pop_options.hpp>
176 #endif // BOOST_ASIO_SSL_OLD_CONTEXT_SERVICE_HPP