Skip to content

Commit

Permalink
Let's Encrypt rate limits have changed from 5 per 7 days to 20 per 7 …
Browse files Browse the repository at this point in the history
  • Loading branch information
sahsanu committed Mar 27, 2016
1 parent f6a7e1b commit 588ab16
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions lectl
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@
# 2016-Feb-10: Created (v0.1)
# 2016-Mar-24: Public release with many fixes (v0.2)
# 2016-Mar-25: Add support to new certificate authority X3 (v0.3)
# 2016-Mar-27: Rate limits have changed from 5 per 7 days to 20 per 7 days (v0.4)
#
# TODO:
# Clean up and comment the code

# Script version/name variables
version='0.3'
version='0.4'
scriptname='lectl'
lastmodification='2016-March-25'
lastmodification='2016-March-27'

_showversion() {
echo "${scriptname} $version (${lastmodification})"
Expand Down Expand Up @@ -96,6 +97,7 @@ columnsans=""
showexpired="1"
expired='&exclude=expired'
nonexpired="non expired "
ratelimit='20'

# Define message functions
_echoerr() { echo "Error: $@" >&2; }
Expand Down Expand Up @@ -238,17 +240,17 @@ echo " "

# Get issued certificates for domain and subdomains (X1)
curl -sS "$crturldomainx1" > "${tempfile}" 2>/dev/null
_checkerror "Failed to retrieve ${crturldomainx1}"
_checkerror "Failed to retrieve ${crturldomain}"

curl -sS "$crturlsubdomainsx1" >> "${tempfile}" 2>/dev/null
_checkerror "Failed to retrieve ${crturlsubdomainsx1}"
_checkerror "Failed to retrieve ${crturlsubdomains}"

# Get issued certificates for domain and subdomains (X3)
curl -sS "$crturldomainx3" >> "${tempfile}" 2>/dev/null
_checkerror "Failed to retrieve ${crturldomainx3}"
_checkerror "Failed to retrieve ${crturldomain2}"

curl -sS "$crturlsubdomainsx3" >> "${tempfile}" 2>/dev/null
_checkerror "Failed to retrieve ${crturlsubdomainsx3}"
_checkerror "Failed to retrieve ${crturlsubdomains2}"

# Put certificates found in variable
certsfound=$(grep '?id' "${tempfile}" | tr -d ' ')
Expand All @@ -270,7 +272,7 @@ for i in $(echo "${certsfound}");do
domainid=$(echo "$i" | awk -F'CN=|>|<' '{print $6}')

curl -sS "${crturldomainid}${id}" > "${tempfile}.${id}" 2>/dev/null
_checkerror "Failed to retrieve ${crturldomainid}${id}"
_checkerror "Failed to retrieve ${crturldomain}"

validfrom=$(sed 's/Not&nbsp;Before:/\r\nBxexfxoxrxex:/g' "${tempfile}.${id}" | awk -F'<BR>' '/^Bxexfxoxrxex:/ {print $1}' | sed 's/Bxexfxoxrxex:&nbsp;//g' | sed 's/&nbsp;/ /g')
validfrom=$(LANG=C;date ${utc} -d "${validfrom}" +'%Y-%b-%d %H:%M %Z')
Expand Down Expand Up @@ -307,13 +309,13 @@ for i in $(echo "${finalresult}" | awk -F';' '{print $3}');do
certdate=$(LANG=C;date $utc -d "$converteddate" +'%s')
daystoexpire=$(((${rightnow}-${certdate})/(60*60*24)))

if [ "${daystoexpire}" -lt "7" ] && [ "${count}" -lt "5" ];then
if [ "${daystoexpire}" -lt "7" ] && [ "${count}" -lt "${ratelimit}" ];then
count=$((count+1))
dentrode="${dentrode}\n${converteddate}"
fi
done

remaining=$((5-count))
remaining=$((${ratelimit}-count))
if [ $remaining -le 0 ];then
lastcert=$(echo -e "${dentrode}" | tail -n1 )
next=$(LANG=C; date ${utc} -d "${lastcert}+7 days 1 minute" +'%A %Y-%b-%d %H:%M:%S %Z')
Expand Down

0 comments on commit 588ab16

Please sign in to comment.