-
Notifications
You must be signed in to change notification settings - Fork 425
Add HTTP client options for SSL/TLS methods #530
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,20 +14,31 @@ | |
boost::network::http::impl::ssl_delegate::ssl_delegate( | ||
asio::io_service &service, bool always_verify_peer, | ||
optional<std::string> certificate_filename, | ||
optional<std::string> verify_path, optional<std::string> certificate_file, | ||
optional<std::string> private_key_file) | ||
optional<std::string> verify_path, | ||
optional<std::string> certificate_file, | ||
optional<std::string> private_key_file, | ||
optional<std::string> ciphers, | ||
long ssl_options) | ||
: service_(service), | ||
certificate_filename_(certificate_filename), | ||
verify_path_(verify_path), | ||
certificate_file_(certificate_file), | ||
private_key_file_(private_key_file), | ||
ciphers_(ciphers), | ||
ssl_options_(ssl_options), | ||
always_verify_peer_(always_verify_peer) {} | ||
|
||
void boost::network::http::impl::ssl_delegate::connect( | ||
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)); | ||
if (ciphers_) { | ||
::SSL_CTX_set_cipher_list(context_->native_handle(), ciphers_->c_str()); | ||
} | ||
if (ssl_options_ != 0) { | ||
context_->set_options(ssl_options_); | ||
} | ||
if (certificate_filename_ || verify_path_) { | ||
context_->set_verify_mode(asio::ssl::context::verify_peer); | ||
if (certificate_filename_) | ||
|
@@ -36,9 +47,10 @@ void boost::network::http::impl::ssl_delegate::connect( | |
} else { | ||
if (always_verify_peer_) { | ||
context_->set_verify_mode(asio::ssl::context::verify_peer); | ||
context_->set_default_verify_paths(); // use openssl default verify paths. uses openssl environment variables SSL_CERT_DIR, SSL_CERT_FILE | ||
} | ||
else | ||
// use openssl default verify paths. uses openssl environment variables | ||
// SSL_CERT_DIR, SSL_CERT_FILE | ||
context_->set_default_verify_paths(); | ||
} else | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This formatting looks weird to me. Please make consistent with the surrounding code, and don't use tab characters... if you can run clang-format on it using the .clang-format configuration in the root of the package. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting. I used the cpp-netlib's .clang-format and clang-format version 3.5.0 (tags/RELEASE_350/final), it should have picked up "UseTab: false". |
||
context_->set_verify_mode(asio::ssl::context::verify_none); | ||
} | ||
if (certificate_file_) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, this
sslv23_client
eventually uses the OpenSSL:::SSLv23_client_method()
, which combined with the recommended:SSL_OP_NO_SSLv3 | SSL_OP_NO_SSLv2
options will negotiate the maximum supported TLS client version. On a base Ubuntu14.04 with OpenSSL 1.0.1f 6 Jan 2014, this implementation, with-DSSL_TXT_TLSV1_2
negotiates TLS1.2 fine.In our projects we add to CMakeLists.txt