pki-bootstrap_pub/src/pki_bootstrap/res/libs/gen_ca-i.sh

61 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
#
# Create CA Intermediate
#
#
# source this file to include the functions
. cfg/pki_funcs.sh
PARAM1=$1
PARAM2=$2
usage() {
echo
echo "Generate a new CA Intermediate certificate"
echo
echo "This program will generate a new certificate authority (CA) intermediate"
echo "It requires a CA certificate used to sign CA Intermediate"
echo "Requires the file \"ca.pem\" that is used to sign the certificates"
echo
echo " usage: gen_ca-i.sh <Org URL> [# of client/server certs]"
echo
echo " example: gen_ca-i.sh skunkworks.acme.xyz \\"
echo " 10 (optional) \\"
exit 1
}
check_params() {
# the parameter must be the URL (not the filename, .cnf)
if [[ -n $PARAM1 ]]; then
if [[ ${PARAM1: -4} == .cnf ]]; then
if [[ ! -f "cfg/${PARAM1}" ]]; then
echo_block "ERROR: file cfg/${PARAM1} is missing"
usage
else
PARAM1=${PARAM1%.*}
fi
else
if [[ ! -f "cfg/${PARAM1}.cnf" ]]; then
echo_block "ERROR: file cfg/${PARAM1}.cnf is missing"
usage
fi
fi
else
usage
fi
if [[ -z $PARAM2 ]]; then
PARAM2=5
fi
}
main() {
# uses global variables: $PARAM1 $PARAM2 $PARAM3
check_cai_pkg
check_params
ca-i_gen_pki $PARAM1 $PARAM2
}
main