Mat*_*ens 6 bash ssl openssl https certificates
我编写了这段代码来获取给定域的 SSL 证书中主题字段的通用名称:
$ 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
Run Code Online (Sandbox Code Playgroud)
然而,这只给了我“主题”值。替代 CN 可能会列在“主题替代名称”字段中。例如:

那么,如何在 Bash 中获取主题备用名称字段的值?
这可能并非在所有情况下都有效,但请尝试
openssl s_client -connect google.com:443 2>&1 | openssl x509 -text | 域名解析