optimize Agunua generator script

Output once per file.
This commit is contained in:
nervuri 2021-04-29 16:05:44 +00:00
parent 1d1371943d
commit c6b971e521
Signed by: nervuri
GPG Key ID: C4769EEA7BA61672
1 changed files with 4 additions and 6 deletions

View File

@ -58,23 +58,21 @@ for cert_file in ../certs/*; do
fi
# Certificate public key (SPKI) fingerprint
echo "$cert" \
fingerprint=$(echo "$cert" \
| openssl x509 -pubkey -noout \
| openssl pkey -pubin -outform der \
| openssl dgst -sha256 -binary \
| openssl enc -base64 -A \
> "$pinning_file"
echo >> "$pinning_file" # newline
| openssl enc -base64 -A)
# Expiry date
enddate=$(echo "$cert" | openssl x509 -enddate -noout | cut -d '=' -f 2)
enddate=$(date -d "$enddate" +"%Y-%m-%dT%H:%M:%SZ" --utc)
echo "$enddate" >> "$pinning_file"
# Start date
startdate=$(echo "$cert" | openssl x509 -startdate -noout | cut -d '=' -f 2)
startdate=$(date -d "$startdate" +"%Y-%m-%dT%H:%M:%SZ" --utc)
echo "$startdate" >> "$pinning_file"
printf "%s\n%s\n%s\n" "$fingerprint" "$enddate" "$startdate" > "$pinning_file"
done