diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-10-05 21:14:23 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-10-05 21:14:23 +0200 |
commit | e160aae0d52b7e7d7403105e110f2e73ebedc5b7 (patch) | |
tree | 43c2085907b693fecc00628aafb2c47421e91086 /system/services/taskserver/certs/generate.ca | |
parent | chore(taskserver/certs/ca.key.pem.gpg): reencrypt with new keys as recipients (diff) | |
download | nixos-server-e160aae0d52b7e7d7403105e110f2e73ebedc5b7.tar.gz nixos-server-e160aae0d52b7e7d7403105e110f2e73ebedc5b7.zip |
refactor(taskserver/certs): Format scripts and allow selecting which certs to generate
Diffstat (limited to '')
-rwxr-xr-x | system/services/taskserver/certs/generate.ca | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/system/services/taskserver/certs/generate.ca b/system/services/taskserver/certs/generate.ca index a9fbc0c..eb0dd5c 100755 --- a/system/services/taskserver/certs/generate.ca +++ b/system/services/taskserver/certs/generate.ca @@ -2,29 +2,26 @@ # Take the correct binary to create the certificates CERTTOOL=$(command -v gnutls-certtool 2>/dev/null || command -v certtool 2>/dev/null) -if [ -z "$CERTTOOL" ] -then - echo "ERROR: No certtool found" >&2 - exit 1 +if [ -z "$CERTTOOL" ]; then + echo "ERROR: No certtool found" >&2 + exit 1 fi . ./vars -if ! [ -f ca.key.pem ] -then - # Create a CA key. - $CERTTOOL \ - --generate-privkey \ - --sec-param $SEC_PARAM \ - --outfile ca.key.pem +if ! [ -f ca.key.pem ]; then + # Create a CA key. + $CERTTOOL \ + --generate-privkey \ + --sec-param $SEC_PARAM \ + --outfile ca.key.pem fi chmod 600 ca.key.pem -if ! [ -f ca.template ] -then - # Sign a CA cert. - cat <<EOF >ca.template +if ! [ -f ca.template ]; then + # Sign a CA cert. + cat <<EOF >ca.template organization = $ORGANIZATION cn = $CN CA country = $COUNTRY @@ -35,13 +32,12 @@ EOF #locality = $LOCALITY fi -if ! [ -f ca.cert.pem ] -then - $CERTTOOL \ - --generate-self-signed \ - --load-privkey ca.key.pem \ - --template ca.template \ - --outfile ca.cert.pem +if ! [ -f ca.cert.pem ]; then + $CERTTOOL \ + --generate-self-signed \ + --load-privkey ca.key.pem \ + --template ca.template \ + --outfile ca.cert.pem fi chmod 600 ca.cert.pem |