From 7f3c38025fd1977dffae882d67737699299fcfd7 Mon Sep 17 00:00:00 2001 From: Alden Torres Date: Wed, 4 Oct 2017 14:19:00 -0400 Subject: [PATCH] making use of openssl API 1.1 compatible --- Jamfile | 2 -- src/session_impl.cpp | 6 ++++++ src/torrent.cpp | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Jamfile b/Jamfile index e5d48b003..7a3e312a2 100644 --- a/Jamfile +++ b/Jamfile @@ -68,8 +68,6 @@ rule linking ( properties * ) # system starting with OpenSSL 1.1 result += crypto ssl ; } - # boost.asio use the pre-1.1 OpenSSL API - result += OPENSSL_API_COMPAT=0x10000000L ; } if libcrypto in $(properties) diff --git a/src/session_impl.cpp b/src/session_impl.cpp index e17242032..7f76138b0 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -139,6 +139,11 @@ namespace { #include #include +// by openssl changelog at https://www.openssl.org/news/changelog.html +// Changes between 1.0.2h and 1.1.0 [25 Aug 2016] +// - Most global cleanup functions are no longer required because they are handled +// via auto-deinit. Affected function CRYPTO_cleanup_all_ex_data() +#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < 0x10100000L namespace { // openssl requires this to clean up internal @@ -155,6 +160,7 @@ namespace { #endif } openssl_global_destructor; } +#endif #endif // TORRENT_USE_OPENSSL diff --git a/src/torrent.cpp b/src/torrent.cpp index e5a6bb6bb..c0d250df3 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -1536,7 +1536,11 @@ namespace libtorrent { using boost::asio::ssl::context; // this is needed for openssl < 1.0 to decrypt keys created by openssl 1.0+ +#if !defined(OPENSSL_API_COMPAT) || (OPENSSL_API_COMPAT < 0x10100000L) OpenSSL_add_all_algorithms(); +#else + OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS | OPENSSL_INIT_ADD_ALL_DIGESTS, nullptr); +#endif // create the SSL context for this torrent. We need to // inject the root certificate, and no other, to