Skip to content

Verify hostname according to rfc2818 #455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions boost/network/protocol/http/client/connection/async_normal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ struct http_async_connection
resolve_(
resolver_, host(request), port_,
request_strand_.wrap(boost::bind(
&this_type::handle_resolved, this_type::shared_from_this(), port_,
&this_type::handle_resolved, this_type::shared_from_this(), host(request), port_,
get_body, callback, generator, boost::arg<1>(), boost::arg<2>())));
if (timeout_ > 0) {
timer_.expires_from_now(boost::posix_time::seconds(timeout_));
Expand Down Expand Up @@ -128,7 +128,7 @@ struct http_async_connection
is_timedout_ = true;
}

void handle_resolved(boost::uint16_t port, bool get_body,
void handle_resolved(string_type host, boost::uint16_t port, bool get_body,
body_callback_function_type callback,
body_generator_function_type generator,
boost::system::error_code const& ec,
Expand All @@ -140,9 +140,9 @@ struct http_async_connection
resolver_iterator iter = boost::begin(endpoint_range);
asio::ip::tcp::endpoint endpoint(iter->endpoint().address(), port);
delegate_->connect(
endpoint, request_strand_.wrap(boost::bind(
endpoint, host, request_strand_.wrap(boost::bind(
&this_type::handle_connected,
this_type::shared_from_this(), port, get_body, callback,
this_type::shared_from_this(), host, port, get_body, callback,
generator, std::make_pair(++iter, resolver_iterator()),
placeholders::error)));
} else {
Expand All @@ -152,7 +152,7 @@ struct http_async_connection
}
}

void handle_connected(boost::uint16_t port, bool get_body,
void handle_connected(string_type host, boost::uint16_t port, bool get_body,
body_callback_function_type callback,
body_generator_function_type generator,
resolver_iterator_pair endpoint_range,
Expand All @@ -173,9 +173,10 @@ struct http_async_connection
asio::ip::tcp::endpoint endpoint(iter->endpoint().address(), port);
delegate_->connect(
endpoint,
host,
request_strand_.wrap(boost::bind(
&this_type::handle_connected, this_type::shared_from_this(),
port, get_body, callback, generator,
host, port, get_body, callback, generator,
std::make_pair(++iter, resolver_iterator()),
placeholders::error)));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace http {
namespace impl {

struct connection_delegate {
virtual void connect(asio::ip::tcp::endpoint &endpoint,
virtual void connect(asio::ip::tcp::endpoint &endpoint, std::string host,
function<void(system::error_code const &)> handler) = 0;
virtual void write(
asio::streambuf &command_streambuf,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace impl {
struct normal_delegate : connection_delegate {
normal_delegate(asio::io_service &service);

virtual void connect(asio::ip::tcp::endpoint &endpoint,
virtual void connect(asio::ip::tcp::endpoint &endpoint, std::string host,
function<void(system::error_code const &)> handler);
virtual void write(
asio::streambuf &command_streambuf,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ boost::network::http::impl::normal_delegate::normal_delegate(
: service_(service) {}

void boost::network::http::impl::normal_delegate::connect(
asio::ip::tcp::endpoint &endpoint,
asio::ip::tcp::endpoint &endpoint, std::string host,
function<void(system::error_code const &)> handler) {
socket_.reset(new asio::ip::tcp::socket(service_));
socket_->async_connect(endpoint, handler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct ssl_delegate : connection_delegate,
optional<std::string> certificate_file,
optional<std::string> private_key_file);

virtual void connect(asio::ip::tcp::endpoint &endpoint,
virtual void connect(asio::ip::tcp::endpoint &endpoint, std::string host,
function<void(system::error_code const &)> handler);
virtual void write(
asio::streambuf &command_streambuf,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ boost::network::http::impl::ssl_delegate::ssl_delegate(
always_verify_peer_(always_verify_peer) {}

void boost::network::http::impl::ssl_delegate::connect(
asio::ip::tcp::endpoint &endpoint,
asio::ip::tcp::endpoint &endpoint, std::string host,
function<void(system::error_code const &)> handler) {
context_.reset(
new asio::ssl::context(service_, asio::ssl::context::sslv23_client));
Expand All @@ -47,6 +47,8 @@ void boost::network::http::impl::ssl_delegate::connect(
boost::asio::ssl::context::pem);
socket_.reset(
new asio::ssl::stream<asio::ip::tcp::socket>(service_, *context_));
if (always_verify_peer_)
socket_->set_verify_callback(boost::asio::ssl::rfc2818_verification(host));
socket_->lowest_layer().async_connect(
endpoint,
::boost::bind(
Expand Down