]> git.street.me.uk Git - andy/dehydrated.git/commitdiff
rewritten command_revoke method (shortened + changed output to look less like one...
authorLukas Schauer <lukas@schauer.so>
Fri, 8 Jan 2016 18:28:19 +0000 (19:28 +0100)
committerLukas Schauer <lukas@schauer.so>
Fri, 8 Jan 2016 19:00:29 +0000 (20:00 +0100)
letsencrypt.sh
test.sh

index 64f10f6fce0ae9b529b9c4818632bc97a58277ec..cc5c8b00d9b1e64161a99ac837fe76d05ac4ba3d 100755 (executable)
@@ -440,6 +440,8 @@ command_sign_domains() {
 command_revoke() {
   init_system
 
+  [[ -n "${CA_REVOKE_CERT}" ]] || _exiterr "Certificate authority doesn't allow certificate revocation."
+
   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)
@@ -451,21 +453,16 @@ command_revoke() {
       cert="$(dirname "${cert}")/${link_target}"
     fi
   fi
-  if [[ ! -f "${cert}" ]]; then
-    echo "ERROR: Could not find certificate ${cert}"
-    exit 1
-  fi
+  [[ -f "${cert}" ]] || _exiterr "Could not find certificate ${cert}"
+
   echo "Revoking ${cert}"
-  if [[ -z "${CA_REVOKE_CERT}" ]]; then
-    echo " + ERROR: Certificate authority doesn't allow certificate revocation." >&2
-    exit 1
-  fi
+
   cert64="$(openssl x509 -in "${cert}" -inform PEM -outform DER | urlbase64)"
   response="$(signed_request "${CA_REVOKE_CERT}" '{"resource": "revoke-cert", "certificate": "'"${cert64}"'"}')"
-  # if there is a problem with our revoke request http_request (via signed_request) will report this and "exit 1" out
+  # if there is a problem with our revoke request _request (via signed_request) will report this and "exit 1" out
   # so if we are here, it is safe to assume the request was successful
-  echo " + SUCCESS"
-  echo " + renaming certificate to ${cert}-revoked"
+  echo " + Done."
+  echo " + Renaming certificate to ${cert}-revoked"
   mv -f "${cert}" "${cert}-revoked"
 }
 
diff --git a/test.sh b/test.sh
index dc41233c3e740ed174b6cf7c07da1212cdc9d593..4b53d67d140b2fc720f43f0daf2788e6e2e93095 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -185,7 +185,7 @@ _TEST "Revoking certificate..."
 ./letsencrypt.sh --revoke "certs/${TMP_URL}/cert.pem" --privkey "certs/${TMP_URL}/privkey.pem" > tmplog 2> errorlog || _FAIL "Script execution failed"
 REAL_CERT="$(readlink -n "certs/${TMP_URL}/cert.pem")"
 _CHECK_LOG "Revoking certs/${TMP_URL}/${REAL_CERT}"
-_CHECK_LOG "SUCCESS"
+_CHECK_LOG "Done."
 _CHECK_FILE "certs/${TMP_URL}/${REAL_CERT}-revoked"
 _CHECK_ERRORLOG