
是否可以使用 openssl 指令來檢查即時網站上 SSL 憑證的密碼?
例如使用類似的東西:
openssl s_client -connect example.com:443 -crlf
上面的命令將返回大量資訊以及密碼:
Cipher : TLS_AES_256_GCM_SHA384
我正在尋找僅返回密碼值的 openssl 命令。
答案1
嘗試 grep
$ echo -n '' | openssl s_client -connect example.com:443 2>&1 | grep -Po "(?<=Cipher is ).*$"
TLS_AES_256_GCM_SHA384
或者你也可以將它包裝成函數,像這樣...
$ function get-s_clientCipher {
echo -n '' |
openssl s_client -connect $1 2>&1 |
grep --perl-regexp --only-matching -- "(?<=Cipher is ).*$";
}
....然後像這樣使用它...
$ get-s_clientCipher example.com:443
TLS_AES_256_GCM_SHA384
但我不確定這是否會對您有幫助。因為結果很大程度取決於您當地的環境。所以它沒有什麼一般意義。 -- 因此,如果您想對伺服器的密碼進行更全面的診斷,請使用類似https://testssl.sh/shell 腳本。 (或如果可以透過網際網路存取伺服器,請嘗試https://www.ssllabs.com/ssltest/)