Package: certbot
Version: 1.6.0-1
Severity: normal
Hello,
the postrm script of certbot has the following code that is run on
purge:
LIVE=0
for cert in /etc/letsencrypt/live/*/cert.pem; do
if [ -e "$cert" ]; then
openssl x509 -in ${cert} -noout -checkend 0 -noout >/dev/null
2>&1
LIVE=$(( ${LIVE} + $? ))
fi
done
if [ $LIVE -eq 0 ]; then
# We have live certs. Prompt for deletion.
... only remove dir with a prompt
else
# No live certs. It's safe to purge
remove_letsencrypt_dir
fi
The logic implmented here is bogus. openssl returns 0 for certs that
are still valid. So removing the letsencrypt directory is only
interactive if *all* found certs are still valid. This includes the
special case that no cert is found at all.
The following should do a better job (untested though):
removeinteractive=false
for cert in /etc/letsencrypt/live/*/cert.pem; do
# is -noout really needed twice here?
if test -e "$cert" && openssl x509 -in ${cert} -noout -checkend 0
-noout >/dev/null 2>&1; then
removeinteractive=true
break
fi
done
if "$removeinteractive"; then
# We have live certs. Prompt for deletion.
... only remove dir with a prompt
else
# No live certs. It's safe to purge
remove_letsencrypt_dir
fi
Best regards
Uwe