verify_callback.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // ssl/detail/verify_callback.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef BOOST_ASIO_SSL_DETAIL_VERIFY_CALLBACK_HPP
  11. #define BOOST_ASIO_SSL_DETAIL_VERIFY_CALLBACK_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/config.hpp>
  16. #include <boost/asio/ssl/verify_context.hpp>
  17. #include <boost/asio/detail/push_options.hpp>
  18. namespace boost {
  19. namespace asio {
  20. namespace ssl {
  21. namespace detail {
  22. class verify_callback_base
  23. {
  24. public:
  25. virtual ~verify_callback_base()
  26. {
  27. }
  28. virtual bool call(bool preverified, verify_context& ctx) = 0;
  29. };
  30. template <typename VerifyCallback>
  31. class verify_callback : public verify_callback_base
  32. {
  33. public:
  34. explicit verify_callback(VerifyCallback callback)
  35. : callback_(callback)
  36. {
  37. }
  38. virtual bool call(bool preverified, verify_context& ctx)
  39. {
  40. return callback_(preverified, ctx);
  41. }
  42. private:
  43. VerifyCallback callback_;
  44. };
  45. } // namespace detail
  46. } // namespace ssl
  47. } // namespace asio
  48. } // namespace boost
  49. #include <boost/asio/detail/pop_options.hpp>
  50. #endif // BOOST_ASIO_SSL_DETAIL_VERIFY_CALLBACK_HPP