Skip to content
Snippets Groups Projects
Commit d9bced96 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

crypto: add TrustList move operator, prevent copy

parent 4d78aea0
Branches
Tags
No related merge requests found
......@@ -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;
};
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment