diff --git a/tools/common.cpp b/tools/common.cpp
index b6550abff7fc0618fce070a8af35ef05f1b61cf8..979274d3549ad82cda67fd704578475aaa29b604 100644
--- a/tools/common.cpp
+++ b/tools/common.cpp
@@ -82,7 +82,7 @@ connectionManagerConfig(const std::filesystem::path& path,
         if (logger)
             logger->debug("Identity announced {}\n", ok);
     };
-    dhtContext.certificateStore = [&](const dht::InfoHash& pk_id) {
+    dhtContext.certificateStore = [certStore](const dht::InfoHash& pk_id) {
         std::vector<std::shared_ptr<dht::crypto::Certificate>> ret;
         if (auto cert = certStore->getCertificate(pk_id.toString()))
             ret.emplace_back(std::move(cert));