Created by
Ossi Herrala
| #!/bin/sh
if [ -z $1 ] || [ -z $2 ]; then
echo "$0 <ca-bundle.crt> <capath>"
exit 1
fi
if [ ! -f $1 ]; then
echo "File not found \"$1\""
exit 2
fi
if [ ! -d $2 ]; then
echo "Directory not found \"$2\""
exit 2
fi
CABUNDLE=$1
TARGET=$2
TEMP=`mktemp -d`
if [ ! -d "$TEMP" ]; then
echo "Temp directory creation failed"
exit 3
fi
( cd $TEMP && csplit -k "$CABUNDLE" '/BEGIN/' '{1000}' >/dev/null )
for i in `ls $TEMP/xx*`; do
name=`openssl x509 -hash -noout -in \$i 2>/dev/null`.0
openssl x509 -in "$i" -out "$TARGET/$name" 2>/dev/null
done
rm -rf "$TEMP"
|