Introduce tool to create dfn-pki style certificate fingerprints

This commit is contained in:
Jan Philipp Timme 2019-03-28 10:42:23 +01:00
parent 5d2f8cb1d3
commit 9985f29d21
1 changed files with 13 additions and 0 deletions

13
bin/dfn_fingerprint_cert_req.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
reqfile=$1
if [[ ! -f "$reqfile" ]]; then
echo "Given certificate request file does not exist: '$reqfile'"
exit 1
fi
# Get fingerprint in format '(stdin)= dcfdf79ac7af887201b813b463051c42102a2ecd'
result=$(openssl req -in "$reqfile" -pubkey -noout | openssl rsa -pubin -text -noout | sed -e '/Modulus:$/d' | sed -e 's/RSA Public-Key: (\(.*\))/Modulus (\1):/' | openssl sha1)
# Convert fingerprint to DFN-PKI format for readability
echo "$result" | cut -d ' ' -f 2 | tr '[:lower:]' '[:upper:]' | sed 's/../&:/g;s/:$//'