diff --git a/src/security/certstore.cpp b/src/security/certstore.cpp
index 3f09c59d90474fd5d7480d1417a45ecfbcdae5b1..877b0177d972f19c2029008d7b45d3a47358a07e 100644
--- a/src/security/certstore.cpp
+++ b/src/security/certstore.cpp
@@ -414,6 +414,19 @@ TrustStore::~TrustStore()
     gnutls_x509_trust_list_deinit(allowed_, false);
 }
 
+TrustStore&
+TrustStore::operator=(TrustStore&& o)
+{
+    unknownCertStatus_ = std::move(o.unknownCertStatus_);
+    certStatus_ = std::move(o.certStatus_);
+    revokedList_ = std::move(o.revokedList_);
+    if (allowed_)
+        gnutls_x509_trust_list_deinit(allowed_, false);
+    allowed_ = std::move(o.allowed_);
+    o.allowed_ = nullptr;
+    return *this;
+}
+
 bool
 TrustStore::addRevocationList(dht::crypto::RevocationList&& crl)
 {
diff --git a/src/security/certstore.h b/src/security/certstore.h
index 8d0f4ede0db8fcdfd88d6e6c619881d0bca08e48..d978bdc606fc580632dc648993be6fcb3fe9bcbd 100644
--- a/src/security/certstore.h
+++ b/src/security/certstore.h
@@ -119,14 +119,7 @@ public:
         o.allowed_ = nullptr;
     }
 
-    TrustStore& operator=(TrustStore&& o) {
-        unknownCertStatus_ = std::move(o.unknownCertStatus_);
-        certStatus_ = std::move(o.certStatus_);
-        revokedList_ = std::move(o.revokedList_),
-        allowed_ = std::move(o.allowed_);
-        o.allowed_ = nullptr;
-        return *this;
-    }
+    TrustStore& operator=(TrustStore&& o);
 
     enum class PermissionStatus {
         UNDEFINED = 0,