More gentls_cert improvements: check for usable CA and improve confirmation prompt in create command
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7266 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
df5ea7f602
commit
e1027f3967
|
@ -12,15 +12,25 @@ OUTFILE="agent.pem"
|
|||
|
||||
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 @@ setup_ca() {
|
|||
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 @@ generate_cert() {
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue