This commit is contained in:
@@ -7,10 +7,16 @@ if [ "$#" -ne 2 ]; then
|
||||
fi
|
||||
certificate=$1
|
||||
list=$2
|
||||
[ -f "$certificate" ] || { echo "certificate does not exist: $certificate" >&2; exit 1; }
|
||||
[ -f "$certificate" ] || {
|
||||
echo "certificate does not exist: $certificate" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
fingerprint=$(openssl x509 -in "$certificate" -outform DER | sha256sum | awk '{print $1}')
|
||||
[ "${#fingerprint}" -eq 64 ] || { echo "could not calculate certificate fingerprint" >&2; exit 1; }
|
||||
[ "${#fingerprint}" -eq 64 ] || {
|
||||
echo "could not calculate certificate fingerprint" >&2
|
||||
exit 1
|
||||
}
|
||||
mkdir -p "$(dirname "$list")"
|
||||
lock="$list.lock"
|
||||
exec 9>"$lock"
|
||||
@@ -22,9 +28,9 @@ fi
|
||||
temporary="${list}.tmp.$$"
|
||||
trap 'rm -f "$temporary"' EXIT
|
||||
if [ -f "$list" ]; then
|
||||
cat "$list" > "$temporary"
|
||||
cat "$list" >"$temporary"
|
||||
fi
|
||||
printf '%s\n' "$fingerprint" >> "$temporary"
|
||||
printf '%s\n' "$fingerprint" >>"$temporary"
|
||||
chmod 600 "$temporary"
|
||||
mv -f "$temporary" "$list"
|
||||
printf '%s\n' "$fingerprint"
|
||||
|
||||
Reference in New Issue
Block a user