How to get domain names (SANs) for TLS certificate using OpenSSL

Use the following command to extract the X509 Subject Alternative Names in human-readable form from any SSL certificate file (cert.pem in this example):

openssl x509 -in cert.pem -noout -text | grep "Subject Alternative Name" --after=1

Example output:

X509v3 Subject Alternative Name: 
    DNS:*.techoverflow.net, DNS:techoverflow.net