[Freeswitch-svn] [commit] r7266 - freeswitch/trunk/scripts

Freeswitch SVN stkn at freeswitch.org
Thu Jan 17 09:37:46 EST 2008


Author: stkn
Date: Thu Jan 17 09:37:45 2008
New Revision: 7266

Modified:
   freeswitch/trunk/scripts/gentls_cert.in

Log:
More gentls_cert improvements: check for usable CA and improve confirmation prompt in create command

Modified: freeswitch/trunk/scripts/gentls_cert.in
==============================================================================
--- freeswitch/trunk/scripts/gentls_cert.in	(original)
+++ freeswitch/trunk/scripts/gentls_cert.in	Thu Jan 17 09:37:45 2008
@@ -12,15 +12,25 @@
 
 umask 037
 
-setup_ca() {
-	echo "Creating new CA..."
+check_ca() {
+	for x in cacert.pem cakey.pem config.tpl; do
+		if [ ! -e "${CONFDIR}/CA/${x}" ]; then
+			return 1
+		fi
+	done
 
-	if [ -e "${CONFDIR}/CA/cacert.pem" ] || [ -e "${CONFDIR}/CA/cakey.pem" ]
-	then
-		echo "existing CA found in \"${CONFDIR}/CA\"!"
+	return 0
+}
+
+setup_ca() {
+	if check_ca; then
+		echo "Existing CA found in \"${CONFDIR}/CA\""
+		echo "(Use \"gentls_cert remove\" to delete)"
 		exit 1
 	fi
 
+	echo "Creating new CA..."
+
 	if [ ! -d "${CONFDIR}/CA" ]; then
 		mkdir -p -m 750 "${CONFDIR}/CA" || exit  1
 	fi
@@ -68,6 +78,11 @@
 generate_cert() {
 	local val=""
 
+	if ! check_ca; then
+		echo "No existing CA found, please create one with \"gentls_cert setup\" first"
+		exit 1
+	fi
+
 	echo "Generating new certificate..."
 
 	echo
@@ -78,9 +93,9 @@
 	echo
 	echo "Certificate filename \"${OUTFILE}\""
 	echo
-	echo "[Enter \"OK\" to accept]"
+	echo "[Is this OK? (y/N)]"
 	read val
-	if [ "${val}" != "OK" ]; then
+	if [ "${val}" != "y" ] && [ "${val}" != "Y" ]; then
 		echo "Aborted"
 		return 2
 	fi



More information about the Freeswitch-svn mailing list