From bfd2c435709de2328caa1b0463836ac7846140de Mon Sep 17 00:00:00 2001 From: Kaladin Light <0.kaladin@gmail.com> Date: Fri, 27 Jan 2017 20:36:53 -0500 Subject: [PATCH] Allow reuse of cert name once revoked. --- scripts/makeOVPN.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/makeOVPN.sh b/scripts/makeOVPN.sh index 6acfd3c..72e5fb8 100644 --- a/scripts/makeOVPN.sh +++ b/scripts/makeOVPN.sh @@ -83,13 +83,23 @@ if [[ -z "${NAME}" ]]; then fi # Check if name is already in use -while read -r line || [ -n "$line" ]; do - if [ "$(echo "$line" | sed -e 's:.*/CN=::')" == "${NAME}" ]; then - echo "Name is already in use." - exit 1 +while read -r line || [ -n "${line}" ]; do + STATUS=$(echo "$line" | awk '{print $1}') + + if [[ "${STATUS}" = "V" ]]; then + CERT=$(echo "$line" | sed -e 's:.*/CN=::') + if [ "${CERT}" == "${NAME}" ]; then + INUSE="1" + fi fi done <${INDEX} +if [ "${INUSE}" == "1" ]; then + printf "\n!! This name is already in use by a Valid Certificate." + printf "\nPlease choose another name or revoke this certificate first.\n" + exit 1 +fi + # Check if name is reserved if [ "${NAME}" == "ta" ] || [ "${NAME}" == "server" ] || [ "${NAME}" == "ca" ]; then echo "Sorry, this is in use by the server and cannot be used by clients."