Skip to content

Instantly share code, notes, and snippets.

@tkuchiki
Last active March 11, 2016 02:22
Show Gist options
  • Save tkuchiki/ed03a21af72962569d62 to your computer and use it in GitHub Desktop.
Save tkuchiki/ed03a21af72962569d62 to your computer and use it in GitHub Desktop.
ワイルドカード証明書が使われているドメインを列挙する
#!/bin/bash
WILDCARD="\*.example.com"
ROUTEFILE=/path/to/routefile
for domain in $(grep rrset ${ROUTEFILE} | awk '{print $2}' | sed -e 's/[",]//g' | sed -e 's/[.]$//g' | sort | uniq); do
if echo $domain | grep ^\* -qs ; then
d=$(echo $domain | sed -e 's/\*/test/')
curl --connect-timeout 1 curl -s --head -v https://${d}/ 2>&1 | grep -qs "Server certificate: ${WILDCARD}"
else
curl --connect-timeout 1 curl -s --head -v https://${domain}/ 2>&1 | grep -qs "Server certificate: ${WILDCARD}"
fi
[ $? -eq 0 ] && echo $domain
done
  • WILDCARD="\*.example.com" を適宜変更
  • grep rrset /path/to/Routefile の部分は以下の様な出力になれば他のものでも良い
dev.example.com
stg.example.com
qa.example.com
prod.example.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment