aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/crypto.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore/crypto.cc')
-rw-r--r--src/libstore/crypto.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/libstore/crypto.cc b/src/libstore/crypto.cc
index caba22c1e..747483afb 100644
--- a/src/libstore/crypto.cc
+++ b/src/libstore/crypto.cc
@@ -1,5 +1,6 @@
#include "crypto.hh"
#include "util.hh"
+#include "globals.hh"
#if HAVE_SODIUM
#include <sodium.h>
@@ -98,4 +99,28 @@ bool verifyDetached(const std::string & data, const std::string & sig,
#endif
}
+PublicKeys getDefaultPublicKeys()
+{
+ PublicKeys publicKeys;
+
+ // FIXME: filter duplicates
+
+ for (auto s : settings.get("binary-cache-public-keys", Strings())) {
+ PublicKey key(s);
+ publicKeys.emplace(key.name, key);
+ }
+
+ for (auto secretKeyFile : settings.get("secret-key-files", Strings())) {
+ try {
+ SecretKey secretKey(readFile(secretKeyFile));
+ publicKeys.emplace(secretKey.name, secretKey.toPublicKey());
+ } catch (SysError & e) {
+ /* Ignore unreadable key files. That's normal in a
+ multi-user installation. */
+ }
+ }
+
+ return publicKeys;
+}
+
}