Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.6KB

  1. //
  2. // ssl/rfc2818_verification.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2015 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 ASIO_SSL_RFC2818_VERIFICATION_HPP
  11. #define ASIO_SSL_RFC2818_VERIFICATION_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include "asio/detail/config.hpp"
  16. #include <string>
  17. #include "asio/ssl/detail/openssl_types.hpp"
  18. #include "asio/ssl/verify_context.hpp"
  19. #include "asio/detail/push_options.hpp"
  20. namespace asio {
  21. namespace ssl {
  22. /// Verifies a certificate against a hostname according to the rules described
  23. /// in RFC 2818.
  24. /**
  25. * @par Example
  26. * The following example shows how to synchronously open a secure connection to
  27. * a given host name:
  28. * @code
  29. * using asio::ip::tcp;
  30. * namespace ssl = asio::ssl;
  31. * typedef ssl::stream<tcp::socket> ssl_socket;
  32. *
  33. * // Create a context that uses the default paths for finding CA certificates.
  34. * ssl::context ctx(ssl::context::sslv23);
  35. * ctx.set_default_verify_paths();
  36. *
  37. * // Open a socket and connect it to the remote host.
  38. * asio::io_context io_context;
  39. * ssl_socket sock(io_context, ctx);
  40. * tcp::resolver resolver(io_context);
  41. * tcp::resolver::query query("host.name", "https");
  42. * asio::connect(sock.lowest_layer(), resolver.resolve(query));
  43. * sock.lowest_layer().set_option(tcp::no_delay(true));
  44. *
  45. * // Perform SSL handshake and verify the remote host's certificate.
  46. * sock.set_verify_mode(ssl::verify_peer);
  47. * sock.set_verify_callback(ssl::rfc2818_verification("host.name"));
  48. * sock.handshake(ssl_socket::client);
  49. *
  50. * // ... read and write as normal ...
  51. * @endcode
  52. */
  53. class rfc2818_verification
  54. {
  55. public:
  56. /// The type of the function object's result.
  57. typedef bool result_type;
  58. /// Constructor.
  59. explicit rfc2818_verification(const std::string& host)
  60. : host_(host)
  61. {
  62. }
  63. /// Perform certificate verification.
  64. ASIO_DECL bool operator()(bool preverified, verify_context& ctx) const;
  65. private:
  66. // Helper function to check a host name against a pattern.
  67. ASIO_DECL static bool match_pattern(const char* pattern,
  68. std::size_t pattern_length, const char* host);
  69. // Helper function to check a host name against an IPv4 address
  70. // The host name to be checked.
  71. std::string host_;
  72. };
  73. } // namespace ssl
  74. } // namespace asio
  75. #include "asio/detail/pop_options.hpp"
  76. #if defined(ASIO_HEADER_ONLY)
  77. # include "asio/ssl/impl/rfc2818_verification.ipp"
  78. #endif // defined(ASIO_HEADER_ONLY)
  79. #endif // ASIO_SSL_RFC2818_VERIFICATION_HPP