Chris@16: // Chris@16: // ssl/old/context_service.hpp Chris@16: // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Chris@16: // Chris@16: // Copyright (c) 2005 Voipster / Indrek dot Juhani at voipster dot com Chris@101: // Copyright (c) 2005-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com) Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: Chris@16: #ifndef BOOST_ASIO_SSL_OLD_CONTEXT_SERVICE_HPP Chris@16: #define BOOST_ASIO_SSL_OLD_CONTEXT_SERVICE_HPP Chris@16: Chris@16: #if defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: # pragma once Chris@16: #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace asio { Chris@16: namespace ssl { Chris@16: namespace old { Chris@16: Chris@16: /// Default service implementation for a context. Chris@16: class context_service Chris@16: #if defined(GENERATING_DOCUMENTATION) Chris@16: : public boost::asio::io_service::service Chris@16: #else Chris@16: : public boost::asio::detail::service_base Chris@16: #endif Chris@16: { Chris@16: private: Chris@16: // The type of the platform-specific implementation. Chris@16: typedef old::detail::openssl_context_service service_impl_type; Chris@16: Chris@16: public: Chris@16: #if defined(GENERATING_DOCUMENTATION) Chris@16: /// The unique service identifier. Chris@16: static boost::asio::io_service::id id; Chris@16: #endif Chris@16: Chris@16: /// The type of the context. Chris@16: #if defined(GENERATING_DOCUMENTATION) Chris@16: typedef implementation_defined impl_type; Chris@16: #else Chris@16: typedef service_impl_type::impl_type impl_type; Chris@16: #endif Chris@16: Chris@16: /// Constructor. Chris@16: explicit context_service(boost::asio::io_service& io_service) Chris@16: : boost::asio::detail::service_base(io_service), Chris@16: service_impl_(boost::asio::use_service(io_service)) Chris@16: { Chris@16: } Chris@16: Chris@16: /// Return a null context implementation. Chris@16: impl_type null() const Chris@16: { Chris@16: return service_impl_.null(); Chris@16: } Chris@16: Chris@16: /// Create a new context implementation. Chris@16: void create(impl_type& impl, context_base::method m) Chris@16: { Chris@16: service_impl_.create(impl, m); Chris@16: } Chris@16: Chris@16: /// Destroy a context implementation. Chris@16: void destroy(impl_type& impl) Chris@16: { Chris@16: service_impl_.destroy(impl); Chris@16: } Chris@16: Chris@16: /// Set options on the context. Chris@16: boost::system::error_code set_options(impl_type& impl, Chris@16: context_base::options o, boost::system::error_code& ec) Chris@16: { Chris@16: return service_impl_.set_options(impl, o, ec); Chris@16: } Chris@16: Chris@16: /// Set peer verification mode. Chris@16: boost::system::error_code set_verify_mode(impl_type& impl, Chris@16: context_base::verify_mode v, boost::system::error_code& ec) Chris@16: { Chris@16: return service_impl_.set_verify_mode(impl, v, ec); Chris@16: } Chris@16: Chris@16: /// Load a certification authority file for performing verification. Chris@16: boost::system::error_code load_verify_file(impl_type& impl, Chris@16: const std::string& filename, boost::system::error_code& ec) Chris@16: { Chris@16: return service_impl_.load_verify_file(impl, filename, ec); Chris@16: } Chris@16: Chris@16: /// Add a directory containing certification authority files to be used for Chris@16: /// performing verification. Chris@16: boost::system::error_code add_verify_path(impl_type& impl, Chris@16: const std::string& path, boost::system::error_code& ec) Chris@16: { Chris@16: return service_impl_.add_verify_path(impl, path, ec); Chris@16: } Chris@16: Chris@16: /// Use a certificate from a file. Chris@16: boost::system::error_code use_certificate_file(impl_type& impl, Chris@16: const std::string& filename, context_base::file_format format, Chris@16: boost::system::error_code& ec) Chris@16: { Chris@16: return service_impl_.use_certificate_file(impl, filename, format, ec); Chris@16: } Chris@16: Chris@16: /// Use a certificate chain from a file. Chris@16: boost::system::error_code use_certificate_chain_file(impl_type& impl, Chris@16: const std::string& filename, boost::system::error_code& ec) Chris@16: { Chris@16: return service_impl_.use_certificate_chain_file(impl, filename, ec); Chris@16: } Chris@16: Chris@16: /// Use a private key from a file. Chris@16: boost::system::error_code use_private_key_file(impl_type& impl, Chris@16: const std::string& filename, context_base::file_format format, Chris@16: boost::system::error_code& ec) Chris@16: { Chris@16: return service_impl_.use_private_key_file(impl, filename, format, ec); Chris@16: } Chris@16: Chris@16: /// Use an RSA private key from a file. Chris@16: boost::system::error_code use_rsa_private_key_file(impl_type& impl, Chris@16: const std::string& filename, context_base::file_format format, Chris@16: boost::system::error_code& ec) Chris@16: { Chris@16: return service_impl_.use_rsa_private_key_file(impl, filename, format, ec); Chris@16: } Chris@16: Chris@16: /// Use the specified file to obtain the temporary Diffie-Hellman parameters. Chris@16: boost::system::error_code use_tmp_dh_file(impl_type& impl, Chris@16: const std::string& filename, boost::system::error_code& ec) Chris@16: { Chris@16: return service_impl_.use_tmp_dh_file(impl, filename, ec); Chris@16: } Chris@16: Chris@16: /// Set the password callback. Chris@16: template Chris@16: boost::system::error_code set_password_callback(impl_type& impl, Chris@16: PasswordCallback callback, boost::system::error_code& ec) Chris@16: { Chris@16: return service_impl_.set_password_callback(impl, callback, ec); Chris@16: } Chris@16: Chris@16: private: Chris@16: // Destroy all user-defined handler objects owned by the service. Chris@16: void shutdown_service() Chris@16: { Chris@16: } Chris@16: Chris@16: // The service that provides the platform-specific implementation. Chris@16: service_impl_type& service_impl_; Chris@16: }; Chris@16: Chris@16: } // namespace old Chris@16: } // namespace ssl Chris@16: } // namespace asio Chris@16: } // namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #endif // BOOST_ASIO_SSL_OLD_CONTEXT_SERVICE_HPP