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
|
umask 037
|
||||||
|
|
||||||
setup_ca() {
|
check_ca() {
|
||||||
echo "Creating new 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" ]
|
return 0
|
||||||
then
|
}
|
||||||
echo "existing CA found in \"${CONFDIR}/CA\"!"
|
|
||||||
|
setup_ca() {
|
||||||
|
if check_ca; then
|
||||||
|
echo "Existing CA found in \"${CONFDIR}/CA\""
|
||||||
|
echo "(Use \"gentls_cert remove\" to delete)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Creating new CA..."
|
||||||
|
|
||||||
if [ ! -d "${CONFDIR}/CA" ]; then
|
if [ ! -d "${CONFDIR}/CA" ]; then
|
||||||
mkdir -p -m 750 "${CONFDIR}/CA" || exit 1
|
mkdir -p -m 750 "${CONFDIR}/CA" || exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -68,6 +78,11 @@ setup_ca() {
|
||||||
generate_cert() {
|
generate_cert() {
|
||||||
local val=""
|
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 "Generating new certificate..."
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
@ -78,9 +93,9 @@ generate_cert() {
|
||||||
echo
|
echo
|
||||||
echo "Certificate filename \"${OUTFILE}\""
|
echo "Certificate filename \"${OUTFILE}\""
|
||||||
echo
|
echo
|
||||||
echo "[Enter \"OK\" to accept]"
|
echo "[Is this OK? (y/N)]"
|
||||||
read val
|
read val
|
||||||
if [ "${val}" != "OK" ]; then
|
if [ "${val}" != "y" ] && [ "${val}" != "Y" ]; then
|
||||||
echo "Aborted"
|
echo "Aborted"
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue