Last active
April 5, 2017 10:44
-
-
Save drscream/e48a78c44e41452714b9342718fa9177 to your computer and use it in GitHub Desktop.
An simple but maybe ugly script to find StartCom and StartSSL certificates on your system!
This file contains hidden or 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
#!/usr/bin/env bash | |
# Thomas Merkel <[email protected]> | |
# PATH to have gnutools installed | |
PATH=/opt/local/bin:${PATH} | |
# Default location to look for certificates (*.pem, *.crt) | |
crt_locations=${crt_locations-'/opt/local/etc /etc/'} | |
# Ignore some system CAs and special files which are no certificate files | |
crt_ignores="mozilla-rootcert-.* privkey.* .*-certbot.pem fullchain.pem chain.pem" | |
# Ignore Let's Encrypt archive folder because we only check live files | |
crt_locations_ignores="/opt/local/etc/letsencrypt/archive" | |
# Lookup | |
for location in ${crt_locations}; do | |
[ ! -d "${location}" ] && continue | |
crts=$(find -L ${location} -type f -iname "*.pem" -o -iname "*.crt") | |
# Loop through all *.pem and *.crt files | |
for crt in ${crts}; do | |
# Ignore certs and ignore locations | |
for crt_ignore in ${crt_ignores}; do | |
[[ $(basename ${crt}) =~ ${crt_ignore} ]] && continue 2 | |
done | |
for crt_locations_ignore in ${crt_locations_ignores}; do | |
[[ $(dirname ${crt}) =~ ${crt_locations_ignore} ]] && continue 2 | |
done | |
# OpenSSL receive information from certificate file | |
x509=$(openssl x509 -in ${crt} -noout -nameopt RFC2253 -issuer 2>/dev/null) | |
# StartSSL/StartCom | |
if echo ${x509} | grep -iq "StartCom" 2>/dev/null; then | |
critical[${#critical[*]}]="${crt}" | |
fi | |
done | |
done | |
# Output | |
if [[ "${critical}" ]]; then | |
echo "STARTCOM: " | |
(for c in "${critical[@]}"; do | |
echo " ${c}" | |
done) | sort -M -k 2 | |
fi |
This file contains hidden or 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
#!/usr/bin/env bash | |
# Thomas Merkel <[email protected]> | |
cmd='curl -Oks https://gist.githubusercontent.com/drscream/e48a78c44e41452714b9342718fa9177/raw/cc70a6435d35d4356af187856664e33892ff7d65/find-startssl-certs.sh && bash find-startssl-certs.sh && rm find-startssl-certs.sh' | |
vmadm list -o uuid,state,type -p | grep -v "KVM" | grep "running" | awk -F \: '{ print $1 }' | while read uuid; do | |
echo ">> ${uuid}" | |
zlogin ${uuid} "${cmd}" < /dev/null | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment