Skip to content

Commit

Permalink
[cryptalgo/SecureSocketPort] : 'try' to avoid the use of mutable
Browse files Browse the repository at this point in the history
  • Loading branch information
msieben committed Jan 27, 2025
1 parent ee1f10e commit e6f00e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Source/cryptalgo/SecureSocketPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ static Core::Time ASN1_ToTime(const ASN1_TIME* input)
// class Certificate
// -----------------------------------------------------------------------------
Certificate::Certificate(const void* certificate)
: _certificate{ const_cast<void*>(certificate) }
: _certificate{ certificate }
{
if (certificate != nullptr) {
VARIABLE_IS_NOT_USED int result = X509_up_ref(static_cast<X509*>(_certificate));
Expand Down Expand Up @@ -400,7 +400,7 @@ Certificate::operator const void* () const
// class Key
// -----------------------------------------------------------------------------
Key::Key(const void* key)
: _key{ const_cast<void*>(key) }
: _key{ key }
{
if (_key != nullptr) {
VARIABLE_IS_NOT_USED int result = EVP_PKEY_up_ref(static_cast<EVP_PKEY*>(_key));
Expand Down
8 changes: 4 additions & 4 deletions Source/cryptalgo/SecureSocketPort.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace Crypto {
Certificate& operator=(const Certificate&) = delete;
Certificate& operator=(Certificate&&) = delete;

Certificate(const Certificate& copy);
explicit Certificate(const Certificate& copy);
Certificate(const std::string& fileName);
Certificate(Certificate&& move) noexcept;
~Certificate();
Expand All @@ -49,7 +49,7 @@ namespace Crypto {
operator const void* () const;

private:
mutable void* _certificate;
void* _certificate;
};

class EXTERNAL Key {
Expand All @@ -58,7 +58,7 @@ namespace Crypto {
Key& operator=(Key&&) = delete;
Key& operator=(const Key&) = delete;

Key(const Key& copy);
explicit Key(const Key& copy);
Key(const string& fileName);
Key(const string& fileName, const string& password);
Key(Key&& move) noexcept;
Expand All @@ -69,7 +69,7 @@ namespace Crypto {
operator const void* () const;

private:
mutable void* _key;
void* _key;
};

class EXTERNAL CertificateStore {
Expand Down

0 comments on commit e6f00e9

Please sign in to comment.