Tinkerbell.Sandbox/deploy/tls/gencerts.sh
Gianluca Arbezzano 6ede8cb2e3 initial commit
2020-08-20 13:53:27 +02:00

31 lines
571 B
Bash
Executable File

#!/usr/bin/env sh
set -eux
cd /certs
if [ ! -f ca-key.pem ]; then
cfssl gencert \
-initca ca.json | cfssljson -bare ca
fi
if [ ! -f server.pem ]; then
cfssl gencert \
-ca=ca.pem \
-ca-key=ca-key.pem \
-config=/ca-config.json \
-profile=server \
server-csr.json |
cfssljson -bare server
fi
cat server.pem ca.pem >bundle.pem.tmp
# only "modify" the file if truly necessary since workflow will serve it with
# modtime info for client caching purposes
if ! cmp -s bundle.pem.tmp bundle.pem; then
mv bundle.pem.tmp bundle.pem
else
rm bundle.pem.tmp
fi