Commit fef0a5f7 authored by Jon Siwek's avatar Jon Siwek

Fix "unused" warnings when using OpenSSL 1.1

Per the OpenSSL CHANGES file:

* OpenSSL 1.1 no longer requires setting locking callbacks and
  previous functions are replaced with no-op compatibility macros.

* SSL_CTX_set_ecdh_auto() is removed (replaced with no-op macro) and
  ECDH support is always enabled by default.
parent 00995256
...@@ -45,6 +45,7 @@ struct CRYPTO_dynlock_value { ...@@ -45,6 +45,7 @@ struct CRYPTO_dynlock_value {
namespace caf { namespace caf {
namespace openssl { namespace openssl {
#if OPENSSL_VERSION_NUMBER < 0x10100000L
static int init_count = 0; static int init_count = 0;
static std::mutex init_mutex; static std::mutex init_mutex;
static std::vector<std::mutex> mutexes; static std::vector<std::mutex> mutexes;
...@@ -74,8 +75,10 @@ static void dynlock_destroy(CRYPTO_dynlock_value* dynlock, ...@@ -74,8 +75,10 @@ static void dynlock_destroy(CRYPTO_dynlock_value* dynlock,
const char* /* file */, int /* line */) { const char* /* file */, int /* line */) {
delete dynlock; delete dynlock;
} }
#endif
manager::~manager() { manager::~manager() {
#if OPENSSL_VERSION_NUMBER < 0x10100000L
std::lock_guard<std::mutex> lock{init_mutex}; std::lock_guard<std::mutex> lock{init_mutex};
--init_count; --init_count;
if (init_count == 0) { if (init_count == 0) {
...@@ -85,6 +88,7 @@ manager::~manager() { ...@@ -85,6 +88,7 @@ manager::~manager() {
CRYPTO_set_dynlock_destroy_callback(nullptr); CRYPTO_set_dynlock_destroy_callback(nullptr);
mutexes = std::vector<std::mutex>(0); mutexes = std::vector<std::mutex>(0);
} }
#endif
} }
void manager::start() { void manager::start() {
...@@ -115,6 +119,7 @@ void manager::init(actor_system_config&) { ...@@ -115,6 +119,7 @@ void manager::init(actor_system_config&) {
CAF_RAISE_ERROR("No private key configured for SSL endpoint"); CAF_RAISE_ERROR("No private key configured for SSL endpoint");
} }
#if OPENSSL_VERSION_NUMBER < 0x10100000L
std::lock_guard<std::mutex> lock{init_mutex}; std::lock_guard<std::mutex> lock{init_mutex};
++init_count; ++init_count;
if (init_count == 1) { if (init_count == 1) {
...@@ -125,6 +130,7 @@ void manager::init(actor_system_config&) { ...@@ -125,6 +130,7 @@ void manager::init(actor_system_config&) {
CRYPTO_set_dynlock_destroy_callback(dynlock_destroy); CRYPTO_set_dynlock_destroy_callback(dynlock_destroy);
// OpenSSL's default thread ID callback should work, so don't set our own. // OpenSSL's default thread ID callback should work, so don't set our own.
} }
#endif
} }
actor_system::module::id_t manager::id() const { actor_system::module::id_t manager::id() const {
......
...@@ -243,7 +243,7 @@ SSL_CTX* session::create_ssl_context() { ...@@ -243,7 +243,7 @@ SSL_CTX* session::create_ssl_context() {
} else { } else {
// No authentication. // No authentication.
SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, nullptr); SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, nullptr);
#ifdef CAF_SSL_HAS_ECDH_AUTO #if defined(CAF_SSL_HAS_ECDH_AUTO) && (OPENSSL_VERSION_NUMBER < 0x10100000L)
SSL_CTX_set_ecdh_auto(ctx, 1); SSL_CTX_set_ecdh_auto(ctx, 1);
#else #else
auto ecdh = EC_KEY_new_by_curve_name(NID_secp384r1); auto ecdh = EC_KEY_new_by_curve_name(NID_secp384r1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment