123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #ifndef BOOST_ASIO_SSL_IMPL_HOST_NAME_VERIFICATION_IPP
- #define BOOST_ASIO_SSL_IMPL_HOST_NAME_VERIFICATION_IPP
- #if defined(_MSC_VER) && (_MSC_VER >= 1200)
- # pragma once
- #endif
- #include <boost/asio/detail/config.hpp>
- #include <cctype>
- #include <cstring>
- #include <boost/asio/ip/address.hpp>
- #include <boost/asio/ssl/host_name_verification.hpp>
- #include <boost/asio/ssl/detail/openssl_types.hpp>
- #include <boost/asio/detail/push_options.hpp>
- namespace boost {
- namespace asio {
- namespace ssl {
- bool host_name_verification::operator()(
- bool preverified, verify_context& ctx) const
- {
- using namespace std;
-
- if (!preverified)
- return false;
-
- int depth = X509_STORE_CTX_get_error_depth(ctx.native_handle());
- if (depth > 0)
- return true;
-
-
- boost::system::error_code ec;
- ip::address address = ip::make_address(host_, ec);
- const bool is_address = !ec;
- (void)address;
- X509* cert = X509_STORE_CTX_get_current_cert(ctx.native_handle());
- if (is_address)
- {
- return X509_check_ip_asc(cert, host_.c_str(), 0) == 1;
- }
- else
- {
- char* peername = 0;
- const int result = X509_check_host(cert,
- host_.c_str(), host_.size(), 0, &peername);
- OPENSSL_free(peername);
- return result == 1;
- }
- }
- }
- }
- }
- #include <boost/asio/detail/pop_options.hpp>
- #endif
|