]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/asio/include/boost/asio/ssl/old/context_service.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / asio / include / boost / asio / ssl / old / context_service.hpp
1 //
2 // ssl/old/context_service.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
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)
7 //
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)
10 //
11
12 #ifndef BOOST_ASIO_SSL_OLD_CONTEXT_SERVICE_HPP
13 #define BOOST_ASIO_SSL_OLD_CONTEXT_SERVICE_HPP
14
15 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 # pragma once
17 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18
19 #include <boost/asio/detail/config.hpp>
20 #include <string>
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>
26
27 #include <boost/asio/detail/push_options.hpp>
28
29 namespace boost {
30 namespace asio {
31 namespace ssl {
32 namespace old {
33
34 /// Default service implementation for a context.
35 class context_service
36 #if defined(GENERATING_DOCUMENTATION)
37 : public boost::asio::io_service::service
38 #else
39 : public boost::asio::detail::service_base<context_service>
40 #endif
41 {
42 private:
43 // The type of the platform-specific implementation.
44 typedef old::detail::openssl_context_service service_impl_type;
45
46 public:
47 #if defined(GENERATING_DOCUMENTATION)
48 /// The unique service identifier.
49 static boost::asio::io_service::id id;
50 #endif
51
52 /// The type of the context.
53 #if defined(GENERATING_DOCUMENTATION)
54 typedef implementation_defined impl_type;
55 #else
56 typedef service_impl_type::impl_type impl_type;
57 #endif
58
59 /// Constructor.
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))
63 {
64 }
65
66 /// Return a null context implementation.
67 impl_type null() const
68 {
69 return service_impl_.null();
70 }
71
72 /// Create a new context implementation.
73 void create(impl_type& impl, context_base::method m)
74 {
75 service_impl_.create(impl, m);
76 }
77
78 /// Destroy a context implementation.
79 void destroy(impl_type& impl)
80 {
81 service_impl_.destroy(impl);
82 }
83
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)
87 {
88 return service_impl_.set_options(impl, o, ec);
89 }
90
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)
94 {
95 return service_impl_.set_verify_mode(impl, v, ec);
96 }
97
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)
101 {
102 return service_impl_.load_verify_file(impl, filename, ec);
103 }
104
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)
109 {
110 return service_impl_.add_verify_path(impl, path, ec);
111 }
112
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)
117 {
118 return service_impl_.use_certificate_file(impl, filename, format, ec);
119 }
120
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)
124 {
125 return service_impl_.use_certificate_chain_file(impl, filename, ec);
126 }
127
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)
132 {
133 return service_impl_.use_private_key_file(impl, filename, format, ec);
134 }
135
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)
140 {
141 return service_impl_.use_rsa_private_key_file(impl, filename, format, ec);
142 }
143
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)
147 {
148 return service_impl_.use_tmp_dh_file(impl, filename, ec);
149 }
150
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)
155 {
156 return service_impl_.set_password_callback(impl, callback, ec);
157 }
158
159 private:
160 // Destroy all user-defined handler objects owned by the service.
161 void shutdown_service()
162 {
163 }
164
165 // The service that provides the platform-specific implementation.
166 service_impl_type& service_impl_;
167 };
168
169 } // namespace old
170 } // namespace ssl
171 } // namespace asio
172 } // namespace boost
173
174 #include <boost/asio/detail/pop_options.hpp>
175
176 #endif // BOOST_ASIO_SSL_OLD_CONTEXT_SERVICE_HPP