Compare the fingerprint of the leaf certificate to the previous file to
check if it needs to be updated or not
Also skip the check if no file is on the disk.
return 0
}
+cmp_certkey() {
+ prev=$1
+ new=$2
+
+ if [ ! -f "$prev" ]; then
+ return 1;
+ fi
+
+ if ! cmp -s <(openssl x509 -in "$prev" -noout -fingerprint -sha256) <(openssl x509 -in "$new" -noout -fingerprint -sha256); then
+ return 1
+ fi
+
+ return 0
+}
+
dump_certificate() {
name=$1
crt_filename=$2
return 1
fi
+ if cmp_certkey "${crt_filename}" "${crt_filename}.${tmp}"; then
+ echo "notice: ${crt_filename} is already up to date"
+ return 0
+ fi
+
# move the current certificates to ".old.timestamp"
mv "${crt_filename}" "${crt_filename}.${d}"
[ "${crt_filename}" != "${key_filename}" ] && mv "${key_filename}" "${key_filename}.${d}"