Add CA hash sidecar for onboarding
This commit is contained in:
@@ -17,6 +17,19 @@ log() {
|
||||
printf '[pikit-certgen] %s\n' "$*"
|
||||
}
|
||||
|
||||
write_ca_hash() {
|
||||
if [ -s "$WEB_ASSETS/pikit-ca.crt" ]; then
|
||||
if command -v sha256sum >/dev/null 2>&1; then
|
||||
sha256sum "$WEB_ASSETS/pikit-ca.crt" | awk '{print $1}' > "$WEB_ASSETS/pikit-ca.sha256"
|
||||
elif command -v openssl >/dev/null 2>&1; then
|
||||
openssl dgst -sha256 "$WEB_ASSETS/pikit-ca.crt" | awk '{print $2}' > "$WEB_ASSETS/pikit-ca.sha256"
|
||||
fi
|
||||
if [ -s "$WEB_ASSETS/pikit-ca.sha256" ]; then
|
||||
chmod 644 "$WEB_ASSETS/pikit-ca.sha256"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
ensure_group() {
|
||||
if ! getent group "$CERT_GROUP" >/dev/null 2>&1; then
|
||||
groupadd "$CERT_GROUP" || true
|
||||
@@ -52,6 +65,7 @@ if [ -s "$CA_CRT" ] && [ -s "$CA_KEY" ] && [ -s "$SRV_KEY" ] && [ -s "$SRV_CRT"
|
||||
chmod 644 "$WEB_ASSETS/pikit-ca.crt"
|
||||
log "Copied CA to web assets."
|
||||
fi
|
||||
write_ca_hash
|
||||
fix_perms
|
||||
log "TLS certs already present; skipping generation."
|
||||
exit 0
|
||||
@@ -97,5 +111,6 @@ fix_perms
|
||||
|
||||
cp "$CA_CRT" "$WEB_ASSETS/pikit-ca.crt"
|
||||
chmod 644 "$WEB_ASSETS/pikit-ca.crt"
|
||||
write_ca_hash
|
||||
|
||||
log "TLS certs generated."
|
||||
|
||||
Reference in New Issue
Block a user