Support cryptographically signed binary caches
NAR info files in binary caches can now have a cryptographic signature
that Nix will verify before using the corresponding NAR file.
To create a private/public key pair for signing and verifying a binary
cache, do:
$ openssl genrsa -out ./cache-key.sec 2048
$ openssl rsa -in ./cache-key.sec -pubout > ./cache-key.pub
You should also come up with a symbolic name for the key, such as
"cache.example.org-1". This will be used by clients to look up the
public key. (It's a good idea to number keys, in case you ever need
to revoke/replace one.)
To create a binary cache signed with the private key:
$ nix-push --dest /path/to/binary-cache --key ./cache-key.sec --key-name cache.example.org-1
The public key (cache-key.pub) should be distributed to the clients.
They should have a nix.conf should contain something like:
signed-binary-caches = *
binary-cache-public-key-cache.example.org-1 = /path/to/cache-key.pub
If all works well, then if Nix fetches something from the signed
binary cache, you will see a message like:
*** Downloading ‘http://cache.example.org/nar/7dppcj5sc1nda7l54rjc0g5l1hamj09j-subversion-1.7.11’ (signed by ‘cache.example.org-1’) to ‘/nix/store/7dppcj5sc1nda7l54rjc0g5l1hamj09j-subversion-1.7.11’...
On the other hand, if the signature is wrong, you get a message like
NAR info file `http://cache.example.org/7dppcj5sc1nda7l54rjc0g5l1hamj09j.narinfo' has an invalid signature; ignoring
Signatures are implemented as a single line appended to the NAR info
file, which looks like this:
Signature: 1;cache.example.org-1;HQ9Xzyanq9iV...muQ==
Thus the signature has 3 fields: a version (currently "1"), the ID of
key, and the base64-encoded signature of the SHA-256 hash of the
contents of the NAR info file up to but not including the Signature
line.
Issue #75.
2014-01-08 15:23:41 +01:00
|
|
|
PERL_MODULES = lib/Nix/Store.pm lib/Nix/Manifest.pm lib/Nix/GeneratePatches.pm lib/Nix/SSH.pm lib/Nix/CopyClosure.pm lib/Nix/Config.pm.in lib/Nix/Utils.pm lib/Nix/Crypto.pm
|
2011-10-10 23:11:08 +02:00
|
|
|
|
2011-10-11 11:31:55 +02:00
|
|
|
all: $(PERL_MODULES:.in=)
|
|
|
|
|
2012-05-11 01:03:23 +02:00
|
|
|
install-exec-local: $(PERL_MODULES:.in=) install-perl-xs
|
2011-10-10 20:12:40 +02:00
|
|
|
$(INSTALL) -d $(DESTDIR)$(perllibdir)/Nix
|
2011-10-11 11:31:55 +02:00
|
|
|
$(INSTALL_DATA) $(PERL_MODULES:.in=) $(DESTDIR)$(perllibdir)/Nix
|
2012-05-11 01:03:23 +02:00
|
|
|
|
|
|
|
if PERL_BINDINGS
|
|
|
|
install-perl-xs:
|
2011-10-10 20:12:40 +02:00
|
|
|
$(INSTALL) -d $(DESTDIR)$(perllibdir)/auto/Nix/Store
|
2012-01-11 16:41:42 +01:00
|
|
|
ln -sfn $(pkglibdir)/libNixStore$(dynlib_suffix) $(DESTDIR)$(perllibdir)/auto/Nix/Store/Store$(dynlib_suffix)
|
2011-10-10 20:12:40 +02:00
|
|
|
|
|
|
|
# Awful hackery to get libtool to build Perl XS bindings.
|
|
|
|
pkglib_LTLIBRARIES = libNixStore.la
|
|
|
|
|
2012-01-18 17:43:48 +01:00
|
|
|
nodist_libNixStore_la_SOURCES = lib/Nix/Store.cc
|
|
|
|
|
|
|
|
CLEANFILES = lib/Nix/Store.cc
|
2011-10-10 20:12:40 +02:00
|
|
|
|
2012-01-11 17:44:42 +01:00
|
|
|
libNixStore_la_LIBADD = $(top_builddir)/src/libstore/libstore.la
|
2011-10-10 20:12:40 +02:00
|
|
|
|
|
|
|
AM_CXXFLAGS = \
|
|
|
|
-I$(top_srcdir)/src -I$(top_srcdir)/src/libutil -I$(top_srcdir)/src/libstore \
|
2012-05-05 03:40:56 +02:00
|
|
|
-I$(shell $(perl) -e 'use Config; print $$Config{archlibexp};')/CORE \
|
|
|
|
-D_FILE_OFFSET_BITS=64
|
2011-10-10 20:12:40 +02:00
|
|
|
|
|
|
|
lib/Nix/Store.cc: lib/Nix/Store.xs
|
2012-10-10 11:10:28 +02:00
|
|
|
$(INSTALL) -d lib/Nix
|
2011-10-10 20:12:40 +02:00
|
|
|
xsubpp $^ -output $@
|
|
|
|
|
2012-05-11 01:03:23 +02:00
|
|
|
else
|
|
|
|
install-perl-xs:
|
|
|
|
endif
|
|
|
|
|
2011-10-11 11:31:55 +02:00
|
|
|
EXTRA_DIST = $(PERL_MODULES) lib/Nix/Store.xs
|
2011-10-10 23:11:08 +02:00
|
|
|
|
|
|
|
include ../substitute.mk
|