dotfiles/bin/dfn_fingerprint_cert_req.sh

13 lines
534 B
Bash
Executable File

#!/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/:$//'