多级证书验签
#!/bin/sh
if [[ "$1" = "" || "$2" = "" ]]; then
echo "certSignVerify.sh CAfiles(自签证书或多级证书) certfile "
exit 0;
fi
#除了最后一个参数,其他参数为CA级证书
touch tmpca.cer
count=$#
tmp=1
for i in "$@"; do
if [ "$tmp" -eq "$count" ] ; then
break;
fi
cat $i >> tmpca.cer
tmp=$[$tmp +1]
done
#读取最后一个参数
#args=$#
#lastargs=${!args}
#echo $lastargs
#echo $(eval echo "\$$#")
openssl verify -CAfile tmpca.cer -verbose $(eval echo "\$$#")
rm -f tmpca.cer
测试用例:
./certSignVerify.sh hbroot.cer hb2root.cer user.cer
输出结果
user.cer: OK