Skip to content

Commit

Permalink
Allow Hydra's binary cache to be signed
Browse files Browse the repository at this point in the history
This requires adding the following to hydra.conf:

  binary_cache_key_name = <key-name>
  binary_cache_private_key_file = <path-to-private-key>

e.g.

  binary_cache_key_name = hydra.nixos.org-1
  binary_cache_private_key_file = /home/hydra/cache-key.sec
  • Loading branch information
edolstra committed Jan 8, 2014
1 parent de26b55 commit a598fe7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lib/Hydra/View/NARInfo.pm
Expand Up @@ -4,6 +4,7 @@ use strict;
use base qw/Catalyst::View/;
use File::Basename;
use Nix::Store;
use Nix::Crypto;

sub process {
my ($self, $c) = @_;
Expand All @@ -29,6 +30,15 @@ sub process {
}
}

# Optionally, sign the NAR info file we just created.
my $privateKeyFile = $c->config->{binary_cache_private_key_file};
my $keyName = $c->config->{binary_cache_key_name};

if (defined $privateKeyFile && defined $keyName) {
my $sig = signString($privateKeyFile, $info);
$info .= "Signature: 1;$keyName;$sig\n";
}

$c->response->body($info);

return 1;
Expand Down

0 comments on commit a598fe7

Please sign in to comment.