revoke: follow symlink, exit with error on non-existing certificate file

This commit is contained in:
Markus Germeier
2015-12-16 19:30:20 +01:00
committed by Lukas Schauer
parent 0ed6a25795
commit c70180364b
2 changed files with 17 additions and 3 deletions
+14 -1
View File
@@ -481,8 +481,21 @@ command_sign_domains() {
# Description: Revoke specified certificate
command_revoke() {
cert="${1}"
if [[ -L "${cert}" ]]; then
# follow symlink and use real certificate name (so we move the real file and not the symlink at the end)
local link_target="$(readlink -n "${cert}")"
if [[ "${link_target}" =~ "/" ]]; then
cert="${link_target}"
else
cert="$(dirname "${cert}")/${link_target}"
fi
fi
if [[ ! -f "${cert}" ]]; then
echo "ERROR: Could not find certificate ${cert}"
exit 1
fi
echo "Revoking ${cert}"
if [ -z "${CA_REVOKE_CERT}" ]; then
if [[ -z "${CA_REVOKE_CERT}" ]]; then
echo " + ERROR: Certificate authority doesn't allow certificate revocation." >&2
exit 1
fi