Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

workaround for boost 1.53 TLS 1.2 #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@ set(BOOST_COMPONENTS system thread filesystem date_time)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
set(BOOST_COMPONENTS ${BOOST_COMPONENTS} regex)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_BOOST_REGEX")
message("legacy GCC detected: boost regex")
add_definitions(-DUSE_BOOST_REGEX)
endif()
endif()
find_package(Boost 1.53.0 COMPONENTS ${BOOST_COMPONENTS} REQUIRED)
if(Boost_MINOR_VERSION LESS 58)
message("legacy boost detected: using TLS 1.2 workaround")
add_definitions(-DBOOST_TLS12_FALLBACK)
endif()
include_directories(SYSTEM ${Boost_INCLUDE_DIR})

if(APPLE)
Expand Down
8 changes: 7 additions & 1 deletion client_https.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ namespace SimpleWeb {
Client(const std::string& server_port_path, bool verify_certificate=true,
const std::string& cert_file=std::string(), const std::string& private_key_file=std::string(),
const std::string& verify_file=std::string()) :
ClientBase<HTTPS>::ClientBase(server_port_path, 443), context(boost::asio::ssl::context::tlsv12) {
#ifdef BOOST_TLS12_FALLBACK
ClientBase<HTTPS>::ClientBase(server_port_path, 443), context(boost::asio::ssl::context::sslv23) {
long disallow_ssl_flags = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1;
context.set_options(boost::asio::ssl::context::default_workarounds | boost::asio::ssl::context::no_sslv2 | disallow_ssl_flags);
#else
ClientBase<HTTPS>::ClientBase(server_port_path, 443), context(boost::asio::ssl::context::tlsv12) {
#endif
if(cert_file.size()>0 && private_key_file.size()>0) {
context.use_certificate_chain_file(cert_file);
context.use_private_key_file(private_key_file, boost::asio::ssl::context::pem);
Expand Down
8 changes: 7 additions & 1 deletion server_https.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ namespace SimpleWeb {
}

Server(const std::string& cert_file, const std::string& private_key_file, const std::string& verify_file=std::string()):
ServerBase<HTTPS>::ServerBase(443), context(boost::asio::ssl::context::tlsv12) {
#ifdef BOOST_TLS12_FALLBACK
ServerBase<HTTPS>::ServerBase(443), context(boost::asio::ssl::context::sslv23) {
long disallow_ssl_flags = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1;
context.set_options(boost::asio::ssl::context::default_workarounds | boost::asio::ssl::context::no_sslv2 | disallow_ssl_flags);
#else
ServerBase<HTTPS>::ServerBase(443), context(boost::asio::ssl::context::tlsv12) {
#endif
context.use_certificate_chain_file(cert_file);
context.use_private_key_file(private_key_file, boost::asio::ssl::context::pem);

Expand Down