Last active
June 3, 2020 16:33
-
-
Save waja/cb6c427543b9dbea4c775ccfb1f308ab to your computer and use it in GitHub Desktop.
Fixing the Breakage from the AddTrust External CA Root Expiration for Apache (https://www.agwa.name/blog/post/fixing_the_addtrust_root_expiration)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# wget https://gist.githubusercontent.com/waja/cb6c427543b9dbea4c775ccfb1f308ab/raw/fix_cert_addtrust_external_expiration_apache.sh -O /tmp/a && bash /tmp/a && apache2ctl -t && service apache2 reload | |
TMPFILE=$(mktemp) | |
trap "{ rm -rf ${TMPFILE}; }" EXIT | |
for CERT in $(grep -P "^( |\t)*SSLCertificateFile" /etc/apache2/sites-enabled/* | awk '{print $3}'); do | |
if [ \( "$(openssl x509 -in ${CERT} -issuer | head -1 | cut -d"=" -f7 | sed 's/^ *//g')" == "Sectigo RSA Domain Validation Secure Server CA" -o "$(openssl x509 -in ${CERT} -issuer | head -1 | cut -d"=" -f7 | sed 's/^ *//g')" == "COMODO RSA Domain Validation Secure Server CA" \) -a ! -L ${CERT} ]; then | |
echo "${CERT}:" | |
openssl crl2pkcs7 -nocrl -certfile ${CERT} | openssl pkcs7 -print_certs > ${TMPFILE} | |
for CA in 'COMODO RSA Certification Authority' 'USERTrust RSA Certification Authority' 'AddTrust External CA Root'; do | |
sed -i "/^subject.*${CA}/q" ${TMPFILE} | |
done | |
sed -Ei "/^(subject|issuer|$)/d" ${TMPFILE} | |
cp -a ${CERT} ${CERT}.orig | |
cp ${TMPFILE} ${CERT} | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment