Skip to content

Commit a495a5b

Browse files
committed
Simplifying logic for whether to verify peers.
1 parent 9d492c3 commit a495a5b

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

boost/network/protocol/http/client/connection/ssl_delegate.ipp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,17 @@ void boost::network::http::ssl_delegate::connect(
2626
options_.openssl_certificate_paths();
2727
std::list<std::string> const & verifier_paths =
2828
options_.openssl_verify_paths();
29-
bool verify_peer = false;
29+
bool verify_peer = !certificate_paths.empty() || !verifier_paths.empty();
30+
if (verify_peer) context_->set_verify_mode(asio::ssl::context::verify_peer);
31+
else context_->set_verify_mode(asio::ssl::context::verify_none);
3032
for (std::list<std::string>::const_iterator it = certificate_paths.begin();
3133
it != certificate_paths.end(); ++it) {
3234
context_->load_verify_file(*it);
33-
verify_peer = true;
3435
}
3536
for (std::list<std::string>::const_iterator it = verifier_paths.begin();
3637
it != verifier_paths.begin(); ++it) {
3738
context_->add_verify_path(*it);
38-
verify_peer = true;
3939
}
40-
if (verify_peer) context_->set_verify_mode(asio::ssl::context::verify_peer);
41-
else context_->set_verify_mode(asio::ssl::context::verify_none);
4240
socket_.reset(new asio::ssl::stream<asio::ip::tcp::socket>(service_, *context_));
4341
socket_->lowest_layer().async_connect(
4442
endpoint,

0 commit comments

Comments
 (0)