From 29497f7920e8c171bdce076718513c2b062961c0 Mon Sep 17 00:00:00 2001 From: redfish Date: Mon, 16 Oct 2017 02:41:32 +0000 Subject: [PATCH 1/2] epee: use boost type for SSL error code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes compile error when building with OpenSSL v1.1: contrib/epee/include/net/net_helper.h: In member function ‘void epee::net_utils::blocked_mode_client::shutdown_ssl()’: contrib/epee/include/net/net_helper.h:579:106: error: ‘SSL_R_SHORT_READ’ was not declared in this scope if (ec.category() == boost::asio::error::get_ssl_category() && ec.value() != ERR_PACK(ERR_LIB_SSL, 0, SSL_R_SHORT_READ)) ^ contrib/epee/include/net/net_helper.h:579:106: note: suggested alternative: ‘SSL_F_SSL_READ’ See boost/asio/ssl/error.hpp. Boost handles differences between OpenSSL versions. cmake: fail if Boost is too old for OpenSSL v1.1 --- CMakeLists.txt | 5 +++++ contrib/epee/include/net/net_helper.h | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3eddfca0e..17f375c91 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -658,6 +658,11 @@ if(NOT Boost_FOUND) die("Could not find Boost libraries, please make sure you have installed Boost or libboost-all-dev (1.58) or the equivalent") elseif(Boost_FOUND) message(STATUS "Found Boost Version: ${Boost_VERSION}") + if (Boost_VERSION VERSION_LESS 1.62 AND NOT (OPENSSL_VERSION VERSION_LESS 1.1)) + message(FATAL_ERROR "Boost older than 1.62 is too old to link with OpenSSL 1.1 or newer. " + "Update Boost or install OpenSSL 1.0 and set path to it when running cmake: " + "cmake -DOPENSSL_ROOT_DIR='/usr/include/openssl-1.0;/usr/lib/openssl-1.0'") + endif() endif() include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) diff --git a/contrib/epee/include/net/net_helper.h b/contrib/epee/include/net/net_helper.h index c8e4c7818..e0d80f964 100644 --- a/contrib/epee/include/net/net_helper.h +++ b/contrib/epee/include/net/net_helper.h @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -576,7 +577,14 @@ namespace net_utils m_io_service.run_one(); } // Ignore "short read" error - if (ec.category() == boost::asio::error::get_ssl_category() && ec.value() != ERR_PACK(ERR_LIB_SSL, 0, SSL_R_SHORT_READ)) + if (ec.category() == boost::asio::error::get_ssl_category() && + ec.value() != +#if BOOST_VERSION >= 106200 + boost::asio::ssl::error::stream_truncated +#else // older Boost supports only OpenSSL 1.0, so 1.0-only macros are appropriate + ERR_PACK(ERR_LIB_SSL, 0, SSL_R_SHORT_READ) +#endif + ) MDEBUG("Problems at ssl shutdown: " << ec.message()); } From 4b228dd356ddc0b5b4ae4fc127d20414b7a5e8c5 Mon Sep 17 00:00:00 2001 From: redfish Date: Mon, 16 Oct 2017 02:43:16 +0000 Subject: [PATCH 2/2] cmake: epee: use var from FindOpenSSL.cmake This fixes linking when path to openssl is defined manually: cmake -DOPENSSL_ROOT_DIR='/usr/include/openssl-1.0;/usr/lib/openssl-1.0' ... This is useful for building with OpenSSL v1.0 when default system installation is v1.1. The linking error is undefined SSL_load_error_strings symbol. This is due to -L /usr/lib/openssl-1.0 not making it onto the linkline (so -lssl pulls in the default system openssl). --- contrib/epee/src/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contrib/epee/src/CMakeLists.txt b/contrib/epee/src/CMakeLists.txt index af3c6ca5f..3b41f415e 100644 --- a/contrib/epee/src/CMakeLists.txt +++ b/contrib/epee/src/CMakeLists.txt @@ -49,6 +49,5 @@ target_link_libraries(epee easylogging ${Boost_FILESYSTEM_LIBRARY} PRIVATE - ssl - crypto + ${OPENSSL_LIBRARIES} ${EXTRA_LIBRARIES})