Skip to content

Commit

Permalink
Refs #22024: Fix: Do not register atexit in OPenSSL. Instead, Comply …
Browse files Browse the repository at this point in the history
…with OpenSSL initialization and destruction.

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
  • Loading branch information
Mario-DL committed Nov 5, 2024
1 parent bc5089c commit 83a748f
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/cpp/security/OpenSSLInit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,21 @@ class OpenSSLInit

OpenSSLInit()
{
#if OPENSSL_VERSION_NUMBER < 0x10100000L
OpenSSL_add_all_algorithms();
#endif // if OPENSSL_VERSION_NUMBER < 0x10100000L
uint64_t opts = OPENSSL_INIT_NO_ATEXIT;
OPENSSL_init_crypto(opts, NULL);
}

~OpenSSLInit()
{
#if OPENSSL_VERSION_NUMBER < 0x10000000L
ERR_remove_state(0);
ENGINE_cleanup();
#elif OPENSSL_VERSION_NUMBER < 0x10100000L
ERR_remove_thread_state(NULL);
ENGINE_cleanup();
#endif // if OPENSSL_VERSION_NUMBER < 0x10000000L
OPENSSL_cleanup();
}

static std::shared_ptr<OpenSSLInit> get_instance()
{
static auto instance = std::make_shared<OpenSSLInit>();
return instance;
}

};

} // namespace security
Expand Down

0 comments on commit 83a748f

Please sign in to comment.