Commit c7018036 authored by Markus Germeier's avatar Markus Germeier Committed by Lukas Schauer

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

parent 0ed6a257
...@@ -481,8 +481,21 @@ command_sign_domains() { ...@@ -481,8 +481,21 @@ command_sign_domains() {
# Description: Revoke specified certificate # Description: Revoke specified certificate
command_revoke() { command_revoke() {
cert="${1}" 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}" 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 echo " + ERROR: Certificate authority doesn't allow certificate revocation." >&2
exit 1 exit 1
fi fi
......
...@@ -182,9 +182,10 @@ _CHECK_ERRORLOG ...@@ -182,9 +182,10 @@ _CHECK_ERRORLOG
# Revoke certificate using certificate key # Revoke certificate using certificate key
_TEST "Revoking certificate..." _TEST "Revoking certificate..."
./letsencrypt.sh --revoke "certs/${TMP_URL}/cert.pem" --privkey "certs/${TMP_URL}/privkey.pem" > tmplog 2> errorlog || _FAIL "Script execution failed" ./letsencrypt.sh --revoke "certs/${TMP_URL}/cert.pem" --privkey "certs/${TMP_URL}/privkey.pem" > tmplog 2> errorlog || _FAIL "Script execution failed"
_CHECK_LOG "Revoking certs/${TMP_URL}/cert.pem" REAL_CERT="$(readlink -n "certs/${TMP_URL}/cert.pem")"
_CHECK_LOG "Revoking certs/${TMP_URL}/${REAL_CERT}"
_CHECK_LOG "SUCCESS" _CHECK_LOG "SUCCESS"
_CHECK_FILE "certs/${TMP_URL}/cert.pem-revoked" _CHECK_FILE "certs/${TMP_URL}/${REAL_CERT}-revoked"
_CHECK_ERRORLOG _CHECK_ERRORLOG
# All done # All done
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment