I wrote this bit of code to get the Common Name of the subject field in the SSL certificate for a given domain:
$ echo -e "GET / HTTP/1.1\nEOT" | openssl s_client -connect google.com:443 2>&1 | grep subject
subject=/C=US/ST=California/L=Mountain View/O=Google Inc/CN=*.google.com
However, this only gives me the “subject” value. Alternative CNs may be listed in the “Subject Alternative Name” field. For example:

So, how can I get the value of the Subject Alternative Name field in Bash?