- Notifications
You must be signed in to change notification settings - Fork425
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
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> 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)); | ||
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. Also, this In our projects we add to CMakeLists.txt # Make sure the OpenSSL/ssl library has a TLS client method.# Prefer the highest version of TLS, but accept 1.2, 1.1, or 1.0.include(CheckLibraryExists)CHECK_LIBRARY_EXISTS(${OPENSSL_SSL_LIBRARY}"TLSv1_2_client_method"""OPENSSL_TLSV12)CHECK_LIBRARY_EXISTS(${OPENSSL_SSL_LIBRARY}"TLSv1_1_client_method"""OPENSSL_TLSV11)CHECK_LIBRARY_EXISTS(${OPENSSL_SSL_LIBRARY}"TLSv1_client_method"""OPENSSL_TLSV10)# Add a define based on the highest TLS version found. Fatal if no TLS client.if(OPENSSL_TLSV12)add_definitions(-DSSL_TXT_TLSV1_2)elseif(OPENSSL_TLSV11)add_definitions(-DSSL_TXT_TLSV1_1)elseif(OPENSSL_TLSV10)add_definitions(-DSSL_TXT_TLSV1)else()message(FATAL"Cannot find any TLS client methods")endif() | ||
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); | ||
// 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_) | ||
Uh oh!
There was an error while loading.Please reload this page.