B #6445: Make RSA (de)encryption thread safe (#2882)

Co-authored-by: Ruben S. Montero <rsmontero@opennebula.org>
(cherry picked from commit 5966e8d60d)
This commit is contained in:
Pavel Czerný authored and Ruben S. Montero committed 2024-01-03 11:01:21 +01:00
1 parent 1802eaf99e
commit 78ac891f7b
1 file changed
+6
+6
View File
@@ -255,6 +255,9 @@ namespace ssl_util
int rsa_public_encrypt(const std::string& in, std::string& out)
{
static RSA * rsa = nullptr;
static std::mutex m;
std::lock_guard lock(m);
if ( rsa == nullptr) //initialize RSA structure
{
@@ -297,6 +300,9 @@ namespace ssl_util
int rsa_private_decrypt(const std::string& in, std::string& out)
{
static RSA * rsa = nullptr;
static std::mutex m;
std::lock_guard lock(m);
if ( rsa == nullptr) //initialize RSA structure
{