From fcb5a03b4819b95be186c4019b4cdcd7e4adbef6 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sat, 5 Dec 2015 16:27:30 +0100 Subject: [PATCH] fix pubMod64 and thumbprint calculation We must strip the trailing newline with `echo -n` before we pass it to perl to convert the hex to binary, not after. --- letsencrypt.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/letsencrypt.sh b/letsencrypt.sh index bc8e206..37beb9d 100755 --- a/letsencrypt.sh +++ b/letsencrypt.sh @@ -92,9 +92,9 @@ if [ ! -e "private_key.pem" ]; then fi pubExponent64="$(printf "%06x" "$(openssl rsa -in private_key.pem -noout -text | grep publicExponent | head -1 | cut -d' ' -f2)" | perl -pe 's/([0-9a-f]{2})/chr hex $1/gie' | urlbase64)" -pubMod64="$(echo -n "$(openssl rsa -in private_key.pem -noout -modulus | cut -d'=' -f2 | perl -pe 's/([0-9a-f]{2})/chr hex $1/gie')" | urlbase64)" +pubMod64="$(echo -n "$(openssl rsa -in private_key.pem -noout -modulus | cut -d'=' -f2)" | perl -pe 's/([0-9a-f]{2})/chr hex $1/gie' | urlbase64)" -thumbprint="$(echo -n "$(echo -n '{"e":"'"${pubExponent64}"'","kty":"RSA","n":"'"${pubMod64}"'"}' | sha256sum | awk '{print $1}' | perl -pe 's/([0-9a-f]{2})/chr hex $1/gie')" | urlbase64)" +thumbprint="$(echo -n "$(echo -n '{"e":"'"${pubExponent64}"'","kty":"RSA","n":"'"${pubMod64}"'"}' | sha256sum | awk '{print $1}')" | perl -pe 's/([0-9a-f]{2})/chr hex $1/gie' | urlbase64)" if [ "${register}" = "1" ]; then echo "+ Registering account key with letsencrypt..." -- 2.47.3