使用 nix-serve 作为二进制缓存时,客户端 nixos 出现“错误:公钥无效”错误

使用 nix-serve 作为二进制缓存时,客户端 nixos 出现“错误:公钥无效”错误

我遇到了以下错误error: public key is not valid

[demo@nixos:~]$ nix-env -i ripgrep
installing 'ripgrep-0.10.0'
these paths will be fetched (0.00 MiB download, 4.76 MiB unpacked):
  /nix/store/xgr3frnb5f13sf3ich8hl8lqbwjqngw9-ripgrep-0.10.0
error: public key is not valid

[demo@nixos:~]$ sudo nix-env -i ripgrep
installing 'ripgrep-0.10.0'
these paths will be fetched (0.00 MiB download, 4.76 MiB unpacked):
  /nix/store/xgr3frnb5f13sf3ich8hl8lqbwjqngw9-ripgrep-0.10.0
error: public key is not valid

我在我的客户端 Nixos 中有以下设置:

  nix = {
    binaryCaches = [
      "https://cache.nixos.org/"
      "http://192.168.56.1:8080"
    ];
    binaryCachePublicKeys = [
      "my-nix-cache:aDrIoY93RjzjnMmNYXlKSL3OerPqIGEiqv70CzwWzQvPejwp/89PN6FWkywTYqhjJ/muRT9cJHT4B8S+0pKCjw="
    ];
    trustedUsers = [ "root" "chris" ];
  };

nix-serve在我正在做的服务器上:

NIX_SECRET_KEY_FILE="/etc/nixos/nixkeys/key.private" nix-serve -p 8080   
2019/09/29-20:44:00 Starman::Server (type Net::Server::PreFork) starting! pid(17383)
Resolved [*]:8080 to [0.0.0.0]:8080, IPv4
Binding to TCP port 8080 on host 0.0.0.0 with IPv4
Setting gid to "100 100 1 17 27 67 100 131"
cat /etc/nixos/nixkeys/key.public 
my-nix-cache:z3o8Kf/PTzehVpMsE2KoYyf5rkU/XCR0+AfEvtKSgo8=

答案1

我刚刚意识到:

my-nix-cache:z3o8Kf/PTzehVpMsE2KoYyf5rkU/XCR0+AfEvtKSgo8=字符串与我在公钥中的内容不匹配:

my-nix-cache:aDrIoY93RjzjnMmNYXlKSL3OerPqIGEiqv70CzwWzQvPejwp/89PN6FWkywTYqhjJ/muRT9cJHT4B8S+0pKCjw=

...修复后它就可以正常工作了:)

我复制的是私钥而不是公钥!

相关内容