]> git.ipfire.org Git - thirdparty/dehydrated.git/commitdiff
fix pubMod64 and thumbprint calculation
authorSimon Ruderich <simon@ruderich.org>
Sat, 5 Dec 2015 15:27:30 +0000 (16:27 +0100)
committerSimon Ruderich <simon@ruderich.org>
Sat, 5 Dec 2015 15:27:30 +0000 (16:27 +0100)
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

index bc8e206b017416ba99556360f4dd0e40e9df9024..37beb9dc3fa59353c4dcb40f00dc80e6e39b64d1 100755 (executable)
@@ -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..."