Skip to content

Commit

Permalink
B #6445: Make RSA (de)encryption thread safe (#2882)
Browse files Browse the repository at this point in the history
Co-authored-by: Ruben S. Montero <[email protected]>
(cherry picked from commit 5966e8d)
  • Loading branch information
paczerny authored and xorel committed Sep 4, 2024
1 parent edcf221 commit 92a6150
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/common/SSLUtil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit 92a6150

Please sign in to comment.