Add -out option to specify filename for new cert, some other minor improvements
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7265 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
64aadd90b1
commit
df5ea7f602
|
@ -8,12 +8,19 @@ TMPFILE="/tmp/fs-ca-$$-$(date +%Y%m%d%H%M%S)"
|
||||||
COMMON_NAME="FreesSWITCH CA"
|
COMMON_NAME="FreesSWITCH CA"
|
||||||
ALT_NAME="DNS:test.freeswitch.org"
|
ALT_NAME="DNS:test.freeswitch.org"
|
||||||
ORG_NAME="FreeSWITCH"
|
ORG_NAME="FreeSWITCH"
|
||||||
|
OUTFILE="agent.pem"
|
||||||
|
|
||||||
umask 037
|
umask 037
|
||||||
|
|
||||||
setup_ca() {
|
setup_ca() {
|
||||||
echo "Creating new CA..."
|
echo "Creating new CA..."
|
||||||
|
|
||||||
|
if [ -e "${CONFDIR}/CA/cacert.pem" ] || [ -e "${CONFDIR}/CA/cakey.pem" ]
|
||||||
|
then
|
||||||
|
echo "existing CA found in \"${CONFDIR}/CA\"!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
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
|
||||||
|
@ -69,9 +76,12 @@ generate_cert() {
|
||||||
echo "ORG_NAME: \"${ORG_NAME}\""
|
echo "ORG_NAME: \"${ORG_NAME}\""
|
||||||
echo "ALT_NAME: \"${ALT_NAME}\""
|
echo "ALT_NAME: \"${ALT_NAME}\""
|
||||||
echo
|
echo
|
||||||
|
echo "Certificate filename \"${OUTFILE}\""
|
||||||
|
echo
|
||||||
echo "[Enter \"OK\" to accept]"
|
echo "[Enter \"OK\" to accept]"
|
||||||
read val
|
read val
|
||||||
if [ "${val}" != "OK" ]; then
|
if [ "${val}" != "OK" ]; then
|
||||||
|
echo "Aborted"
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -91,7 +101,7 @@ generate_cert() {
|
||||||
-extensions ext -days ${DAYS} -sha1 >/dev/null || exit 1
|
-extensions ext -days ${DAYS} -sha1 >/dev/null || exit 1
|
||||||
|
|
||||||
cat "${CONFDIR}/CA/cacert.pem" > "${CONFDIR}/cafile.pem"
|
cat "${CONFDIR}/CA/cacert.pem" > "${CONFDIR}/cafile.pem"
|
||||||
cat "${TMPFILE}.crt" "${TMPFILE}.key" > "${CONFDIR}/agent.pem"
|
cat "${TMPFILE}.crt" "${TMPFILE}.key" > "${CONFDIR}/${OUTFILE}"
|
||||||
|
|
||||||
rm "${TMPFILE}.cfg" "${TMPFILE}.crt" "${TMPFILE}.key" "${TMPFILE}.req"
|
rm "${TMPFILE}.cfg" "${TMPFILE}.crt" "${TMPFILE}.key" "${TMPFILE}.req"
|
||||||
|
|
||||||
|
@ -99,7 +109,7 @@ generate_cert() {
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_ca() {
|
remove_ca() {
|
||||||
echo "Cleaning CA"
|
echo "Removing CA"
|
||||||
|
|
||||||
if [ ! -d "${CONFDIR}/CA" ]; then
|
if [ ! -d "${CONFDIR}/CA" ]; then
|
||||||
rm "${CONFDIR}/CA/"*
|
rm "${CONFDIR}/CA/"*
|
||||||
|
@ -126,6 +136,10 @@ while [ $# -gt 0 ]; do
|
||||||
shift
|
shift
|
||||||
ORG_NAME="$1"
|
ORG_NAME="$1"
|
||||||
;;
|
;;
|
||||||
|
-out)
|
||||||
|
shift
|
||||||
|
OUTFILE="$1"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
@ -157,14 +171,17 @@ case ${command} in
|
||||||
* commands:
|
* commands:
|
||||||
|
|
||||||
setup - Setup new CA
|
setup - Setup new CA
|
||||||
create - Create new certificate (overwriting old!)
|
|
||||||
remove - Remove CA
|
remove - Remove CA
|
||||||
|
|
||||||
|
create - Create new certificate (overwriting old!)
|
||||||
|
|
||||||
|
|
||||||
* options:
|
* options:
|
||||||
|
|
||||||
-cn Set common name
|
-cn Set common name
|
||||||
-alt Set alternative name (use prefix 'DNS:' or 'URI:')
|
-alt Set alternative name (use prefix 'DNS:' or 'URI:')
|
||||||
-org Set organization name
|
-org Set organization name
|
||||||
|
-out Filename for new certificate (create only)
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Reference in New Issue