summaryrefslogtreecommitdiffstats
path: root/check-vhost-cert
blob: 6dcdcebee5d849fadea774f828adf367912ca58d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash

usage() {
  echo "Usage: $(basename "$0") <vhost>"
}

if [[ -z "$1" ]]; then
  usage
  exit 1
fi

vhost="$1"

echo "Checking https://${vhost}:443..."
openssl s_client \
  -connect "${vhost}:443" \
  -servername "$vhost" \
  <<<"$(echo -en "Host: ${vhost}\nGET /\n")" |& \
openssl x509 -text | \
grep -Eo '(Subject|DNS):.*?'