mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 13:40:28 +03:00
Merge pull request #121750 from m1cr0man/master
nixos/acme: Ensure certs are always protected
This commit is contained in:
commit
dc940ecdb3
2 changed files with 27 additions and 13 deletions
|
@ -46,6 +46,7 @@ let
|
|||
serviceConfig = commonServiceConfig // {
|
||||
StateDirectory = "acme/.minica";
|
||||
BindPaths = "/var/lib/acme/.minica:/tmp/ca";
|
||||
UMask = 0077;
|
||||
};
|
||||
|
||||
# Working directory will be /tmp
|
||||
|
@ -54,8 +55,6 @@ let
|
|||
--ca-key ca/key.pem \
|
||||
--ca-cert ca/cert.pem \
|
||||
--domains selfsigned.local
|
||||
|
||||
chmod 600 ca/*
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -196,6 +195,7 @@ let
|
|||
|
||||
serviceConfig = commonServiceConfig // {
|
||||
Group = data.group;
|
||||
UMask = 0027;
|
||||
|
||||
StateDirectory = "acme/${cert}";
|
||||
|
||||
|
@ -220,10 +220,12 @@ let
|
|||
cat cert.pem chain.pem > fullchain.pem
|
||||
cat key.pem fullchain.pem > full.pem
|
||||
|
||||
chmod 640 *
|
||||
|
||||
# Group might change between runs, re-apply it
|
||||
chown 'acme:${data.group}' *
|
||||
|
||||
# Default permissions make the files unreadable by group + anon
|
||||
# Need to be readable by group
|
||||
chmod 640 *
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -340,8 +342,6 @@ let
|
|||
fi
|
||||
|
||||
mv domainhash.txt certificates/
|
||||
chmod 640 certificates/*
|
||||
chmod -R u=rwX,g=,o= accounts/*
|
||||
|
||||
# Group might change between runs, re-apply it
|
||||
chown 'acme:${data.group}' certificates/*
|
||||
|
@ -357,6 +357,10 @@ let
|
|||
ln -sf fullchain.pem out/cert.pem
|
||||
cat out/key.pem out/fullchain.pem > out/full.pem
|
||||
fi
|
||||
|
||||
# By default group will have no access to the cert files.
|
||||
# This chmod will fix that.
|
||||
chmod 640 out/*
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue