7
7
// (See accompanying file LICENSE_1_0.txt or copy at
8
8
// http://www.boost.org/LICENSE_1_0.txt)
9
9
10
- #include < boost/network/protocol/http/client/connection/ssl_delegate.hpp>
11
10
#include < boost/asio/ssl.hpp>
12
11
#include < boost/bind.hpp>
12
+ #include < boost/network/protocol/http/client/connection/ssl_delegate.hpp>
13
13
14
14
boost::network::http::impl::ssl_delegate::ssl_delegate (
15
15
asio::io_service &service, bool always_verify_peer,
16
16
optional<std::string> certificate_filename,
17
- optional<std::string> verify_path,
18
- optional<std::string> certificate_file,
19
- optional<std::string> private_key_file,
20
- optional<std::string> ciphers,
17
+ optional<std::string> verify_path, optional<std::string> certificate_file,
18
+ optional<std::string> private_key_file, optional<std::string> ciphers,
21
19
long ssl_options)
22
20
: service_(service),
23
21
certificate_filename_(std::move(certificate_filename)),
@@ -29,15 +27,19 @@ boost::network::http::impl::ssl_delegate::ssl_delegate(
29
27
always_verify_peer_(always_verify_peer) {}
30
28
31
29
void boost::network::http::impl::ssl_delegate::connect (
32
- asio::ip::tcp::endpoint &endpoint, std::string host, boost::uint16_t source_port,
30
+ asio::ip::tcp::endpoint &endpoint, std::string host,
31
+ boost::uint16_t source_port,
33
32
function<void (system::error_code const &)> handler) {
34
33
context_.reset (
35
- new asio::ssl::context (service_, asio::ssl::context::sslv23_client));
34
+ new asio::ssl::context (asio::ssl::context::method ::sslv23_client));
36
35
if (ciphers_) {
37
36
::SSL_CTX_set_cipher_list (context_->native_handle (), ciphers_->c_str());
38
37
}
39
38
if (ssl_options_ != 0 ) {
40
39
context_->set_options (ssl_options_);
40
+ } else {
41
+ // By default, disable v3 support.
42
+ context_->set_options (asio::ssl::context::no_sslv3);
41
43
}
42
44
if (certificate_filename_ || verify_path_) {
43
45
context_->set_verify_mode (asio::ssl::context::verify_peer);
@@ -50,8 +52,9 @@ void boost::network::http::impl::ssl_delegate::connect(
50
52
// use openssl default verify paths. uses openssl environment variables
51
53
// SSL_CERT_DIR, SSL_CERT_FILE
52
54
context_->set_default_verify_paths ();
53
- } else
55
+ } else {
54
56
context_->set_verify_mode (asio::ssl::context::verify_none);
57
+ }
55
58
}
56
59
if (certificate_file_)
57
60
context_->use_certificate_file (*certificate_file_,
@@ -60,9 +63,10 @@ void boost::network::http::impl::ssl_delegate::connect(
60
63
context_->use_private_key_file (*private_key_file_,
61
64
boost::asio::ssl::context::pem);
62
65
63
- tcp_socket_.reset (new asio::ip::tcp::socket (service_, asio::ip::tcp::endpoint (asio::ip::tcp::v4 (), source_port)));
64
- socket_.reset (
65
- new asio::ssl::stream<asio::ip::tcp::socket&>(*(tcp_socket_.get ()), *context_));
66
+ tcp_socket_.reset (new asio::ip::tcp::socket (
67
+ service_, asio::ip::tcp::endpoint (asio::ip::tcp::v4 (), source_port)));
68
+ socket_.reset (new asio::ssl::stream<asio::ip::tcp::socket &>(
69
+ *(tcp_socket_.get ()), *context_));
66
70
67
71
if (always_verify_peer_)
68
72
socket_->set_verify_callback (boost::asio::ssl::rfc2818_verification (host));
@@ -109,5 +113,4 @@ void boost::network::http::impl::ssl_delegate::disconnect() {
109
113
110
114
boost::network::http::impl::ssl_delegate::~ssl_delegate () {}
111
115
112
- #endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SSL_DELEGATE_IPP_20110819 \
113
- */
116
+ #endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SSL_DELEGATE_IPP_20110819
0 commit comments