diff --git a/bin/dfn_fingerprint_cert_req.sh b/bin/dfn_fingerprint_cert_req.sh new file mode 100755 index 0000000..df3302a --- /dev/null +++ b/bin/dfn_fingerprint_cert_req.sh @@ -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/:$//' \ No newline at end of file