diff --git a/include/opendht/crypto.h b/include/opendht/crypto.h index 4d4cec72212bda959b16c3f7f832afd2442c01f6..a9ebe5bf4f370455b598ad5e1fe930653329e84a 100644 --- a/include/opendht/crypto.h +++ b/include/opendht/crypto.h @@ -470,6 +470,10 @@ struct OPENDHT_PUBLIC TrustList }; TrustList(); + TrustList(TrustList&& o) : trust(std::move(o.trust)) { + o.trust = nullptr; + } + TrustList& operator=(TrustList&& o); ~TrustList(); void add(const Certificate& crt); void add(const RevocationList& crl); @@ -477,6 +481,8 @@ struct OPENDHT_PUBLIC TrustList VerifyResult verify(const Certificate& crt) const; private: + TrustList(const TrustList& o) = delete; + TrustList& operator=(const TrustList& o) = delete; gnutls_x509_trust_list_t trust; }; diff --git a/src/crypto.cpp b/src/crypto.cpp index c74d0cb162976bdd71750c893f5342e55843ccae..de50fb9bc9fd3b4e3c2ce60ee3f458b35ee21198 100644 --- a/src/crypto.cpp +++ b/src/crypto.cpp @@ -1180,6 +1180,15 @@ TrustList::~TrustList() { gnutls_x509_trust_list_deinit(trust, 1); } +TrustList& +TrustList::operator=(TrustList&& o) +{ + if (trust) + gnutls_x509_trust_list_deinit(trust, true); + trust = std::move(o.trust); + o.trust = nullptr; +} + void TrustList::add(const Certificate& crt) { auto chain = crt.getChainWithRevocations(true);