CA: add a error check

This commit is contained in:
Li Chen 2013-10-26 18:29:22 +02:00
parent fa6fc60759
commit eed6c42595

View file

@ -50,11 +50,11 @@ case $1 in
-selfsign -extensions v3_ca -infiles ${TOP_DIR}/${CAREQ}
;;
"-newserver" )
echo -e "${GREEN}Making the Server key and cert${COLOR_RST}"
if ! [ -f ${TOP_DIR}/private/${CAKEY} ]; then
echo -e "${RED}Can not found the CA's key${COLOR_RST}"
exit 2
fi
echo -e "${GREEN}Making the Server key and cert${COLOR_RST}"
sed -i 's/=.*#COMMONNAME/= FIC2014 Server #COMMONNAME/' $OPENSSL_CONF
openssl req -batch -new -keyout server.key -out server.csr -days ${DAYS}
echo -e "${GREEN}Signing the Server crt${COLOR_RST}"
@ -72,6 +72,10 @@ case $1 in
[ $# -ne 2 ] && "Usage: $0 -newclient NAME"
echo -e "${GREEN}Making the client key and csr${COLOR_RST}"
if ! [ -f ${TOP_DIR}/private/${CAKEY} ]; then
echo -e "${RED}Can not found the CA's key${COLOR_RST}"
exit 2
fi
sed -i "s/=.*#COMMONNAME/= $2#COMMONNAME/" $OPENSSL_CONF
sed -i "s/=.*#CERTTYPE/= client #CERTTYPE/" $OPENSSL_CONF