Skip to content

Instantly share code, notes, and snippets.

@pior
Created September 20, 2017 04:01
Show Gist options
  • Select an option

  • Save pior/b5d41460f6857d71bd485d1e418dacd7 to your computer and use it in GitHub Desktop.

Select an option

Save pior/b5d41460f6857d71bd485d1e418dacd7 to your computer and use it in GitHub Desktop.
Fetch some information from a host or an url
httpinfo () {
local urlorhost=$1
local host=${urlorhost#*//}
local bold=$(tput setaf 37);
local reset=$(tput sgr0);
echo "${bold}DNS records:${reset}"
dig +nocmd ${host} any +multiline +noall +answer;
echo ""
echo "${bold}TLS certificates:${reset}"
curl --insecure -v https://${host} 2>&1 | awk 'BEGIN { cert=0 } /^\* Server certificate:/ { cert=1 } /^\*/ { if (cert) print }'
echo ""
echo "${bold}HTTP HEAD method (with TLS):${reset}"
curl -I https://${host}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment