2019-01-02 07:30:04 +05:30
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Get configuration
|
|
|
|
if [ -f /etc/make-ca.conf ]; then
|
|
|
|
. /etc/make-ca.conf
|
|
|
|
else
|
|
|
|
#Use defaults if make-ca.conf does not exist
|
|
|
|
ANCHORDIR="/etc/pki/anchors"
|
|
|
|
ANCHORLIST="/etc/pki/anchors.md5sums"
|
|
|
|
LOCALDIR="/etc/ssl/local"
|
|
|
|
MD5SUM="/usr/bin/md5sum"
|
|
|
|
CERTLIST=""
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Dump to a temporary directory
|
|
|
|
TEMPDIR=`mktemp -d`
|
|
|
|
/usr/bin/trust extract --filter=certificates \
|
|
|
|
--format=openssl-directory \
|
|
|
|
--overwrite \
|
|
|
|
"${TEMPDIR}"
|
|
|
|
|
2019-01-02 07:39:21 +05:30
|
|
|
# Create a list of anchors that were not present or have been modified
|
2019-01-02 07:30:04 +05:30
|
|
|
"${MD5SUM}" "${ANCHORDIR}"/*.pem > "${TEMPDIR}/anchors.md5sums"
|
|
|
|
diff -au "${ANCHORLIST}" "${TEMPDIR}/anchors.md5sums" > "${TEMPDIR}/diff"
|
|
|
|
grep "^+[a-z,0-9]" "${TEMPDIR}/diff" | cut -d " " -f 3 > "${TEMPDIR}/certlist"
|
|
|
|
|
|
|
|
echo -e "\nThe following certificates have local modifications:\n"
|
2019-01-02 07:39:21 +05:30
|
|
|
|
2019-01-02 07:30:04 +05:30
|
|
|
# Copy new certificates to LOCALDIR
|
|
|
|
for certificate in `cat "${TEMPDIR}/certlist"` ; do
|
|
|
|
LABEL=`grep -m 1 "label:" "${certificate}"`
|
|
|
|
LABELNEW=`echo "${LABEL}" | /bin/sed -e 's@^label: @@' -e 's@"@@g' -e 's@ @_@g'`
|
|
|
|
cp -f "${TEMPDIR}/${LABELNEW}.pem" "${LOCALDIR}"
|
|
|
|
echo -e "${LABELNEW}"
|
|
|
|
unset LABEL LABELNEW
|
|
|
|
done
|
|
|
|
|
|
|
|
# Clean up
|
|
|
|
rm -rf "${TEMPDIR}"
|
|
|
|
unset ANCHORDIR ANCHORLIST LOCALDIR CERTLIST TEMPDIR
|
|
|
|
|