Última atividade 6 months ago

fix_cert_addtrust_external_expiration_apache.sh Bruto
1#!/bin/bash
2# 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
3TMPFILE=$(mktemp)
4trap "{ rm -rf ${TMPFILE}; }" EXIT
5for CERT in $(grep -P "^( |\t)*SSLCertificateFile" /etc/apache2/sites-enabled/* | awk '{print $3}'); do
6 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
7 echo "${CERT}:"
8 openssl crl2pkcs7 -nocrl -certfile ${CERT} | openssl pkcs7 -print_certs > ${TMPFILE}
9 for CA in 'COMODO RSA Certification Authority' 'USERTrust RSA Certification Authority' 'AddTrust External CA Root'; do
10 sed -i "/^subject.*${CA}/q" ${TMPFILE}
11 done
12 sed -Ei "/^(subject|issuer|$)/d" ${TMPFILE}
13 cp -a ${CERT} ${CERT}.orig
14 cp ${TMPFILE} ${CERT}
15 fi
16done
17