-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
store URI: introduce multiple signatures support #12976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Erf, miss-clicked, I wanted to open this as a draft, sorry for the ping :( So, it seems to work, but I only tested that in a ad-hoc fashion for now: #!/usr/bin/env bash
set -euo pipefail
tmpstore=$(mktemp -d)
trap 'rm -rf $tmpstore' EXIT
./nix key generate-secret --key-name cache.alternativebit.fr > key1
./nix key generate-secret --key-name cache.alternativebit.fr > key2
hellopath=$(nix build --print-out-paths nixpkgs#hello)
./nix copy --to "file://${tmpstore}?secret-keys=$PWD/key1,$PWD/key2" "$hellopath"
tree "$tmpstore"
for file in "$tmpstore"/*.narinfo; do
if [ $(cat "$file" | grep -E '^Sig: cache.alternativebit.fr' | wc -l) -ne 2 ]; then
echo "ERROR: Cannot find 2 signatures in ${file}"
cat "${file}"
exit 1
else
echo "Found 2 signatures in ${file}"
fi
done
This script should be converted in a proper functional test, but I'm not familiar with those yet. I'll have a look and see how it works in the next few days. Once we convert this into a proper test, we can undraft this PR. Reviews welcome in the meantime. |
960818f
to
876ebcc
Compare
#11139 my PR will allow JSON for lists, FYI. |
@picnoir could you extend ./tests/functional/signing.sh with this store path syntax? |
Ok. I'm going to add a ad-hoc JSON-style list parser for this1. Unless we already have access to a proper JSON parser? I'll have a look. (Edit: there is) That way, we don't create a direct dependency between #11139 and this PR, and we won't have to support multiple syntax for this URI param. Footnotes
|
Added the functional test as suggested by mic92. @Ericson2314 for the JSON syntax part, would you prefer me to adopt the JSON format from the get go in this PR or would you prefer adding that in #11139 ? |
Add a `secretKeyFiles` URI parameter in the store URIs receiving a coma-separated list of Nix signing keyfiles. For instance: nix copy --to "file:///tmp/store?secret-keys=/tmp/key1,/tmp/key2" \ "$(nix build --print-out-paths nixpkgs#hello)" The keys passed through this new store URI parameter are merged with the key specified in the `secretKeyFile` parameter, if any. We'd like to rotate the signing key for cache.nixos.org. To simplify the transition, we'd like to sign the new paths with two keys: the new one and the current one. With this, the cache can support nix configurations only trusting the new key and legacy configurations only trusting the current key. See NixOS/rfcs#149 for more informations behind the motivation.
I tried to implement this JSON configuration here: picnoir@903a2aa Two issues:
Un-drafting the PR with the comma-separated style for now. |
Sorry @picnoir, I was not clear. What I meant was that I want to get that one working, land it, and then your change should be an easy to make on top. I didn't mean to ask you to go implement JSON settings values for this yourself. |
Performance note: we'll be computing the nar fingerprint once for each key: Line 25 in 903a2aa
We should probably memoize the fingerprint here: nix/src/libstore/realisation.cc Line 119 in 903a2aa
|
This is a small optimization used when we're signing a narinfo for multiple keys in one go. Using this sign variant, we only compute the NAR fingerprint once, then sign it with all the keys.
Note for readers: the pointer indirection is necessary because of the We're not really using this abstraction through and it could potentially be removed? It was introduced for the remote signing mechanism, but the rest did not land and seem stalled. |
Since you also proposed to work on the remote signer, maybe we can remove it for a bit longer. |
Add a
secretKeyFiles
URI parameter in the store URIs receiving a coma-separated list of Nix signing keyfiles.For instance:
The keys passed through this new store URI parameter are merged with the key specified in the
secretKeyFile
parameter, if any.Motivation
We'd like to rotate the signing key for cache.nixos.org. To simplify the transition, we'd like to sign the new paths with two keys: the new one and the current one. With this, the cache can support nix configurations only trusting the new key and legacy configurations only trusting the current key.
See NixOS/rfcs#149 for more informations behind the motivation.
Context
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.