openssl s_client
ネットワーク
書き方
openssl s_client -connect <host>:443 -servername <host>TLS 接続を素で開き、証明書と握手の過程をのぞきます。`-servername` を省くと一つの住所に多くの site を置くサーバーが既定の証明書を返して「別物」が見え、`< /dev/null` を付けないと入力を待って止まったままになります。
よく使うオプション
| オプション | 意味 |
|---|---|
| -connect host:443 | Where to open the TLS connection. |
| -servername <host> | The SNI name. Without it a shared host serves its default certificate. |
| -showcerts | Print the whole chain the server sent, not just the leaf. |
| -tls1_2 / -tls1_3 | Force one protocol version, to test what the server still accepts. |
| -verify_return_error | Fail instead of continuing when the chain does not validate. |
| < /dev/null | Close stdin, or the command sits and waits forever. |
例
openssl s_client -connect example.com:443 -servername example.com < /dev/null 2>/dev/null | openssl x509 -noout -datesWhen the certificate expires.
openssl s_client -connect example.com:443 -showcerts < /dev/nullInspect the full chain for a missing intermediate.
つながらないとき、どこまで行けたのかを絞ります — 名前が引けないのか、経路がないのか、ポートが閉じているのか。
読み方
- 角括弧 [ ] は省いてよい部分です。
- 三点 … は複数並べられるという意味です。
- オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。
よくある質問
Q. openssl s_client は何をしますか。
TLS 接続を素で開き、証明書と握手の過程をのぞきます。`-servername` を省くと一つの住所に多くの site を置くサーバーが既定の証明書を返して「別物」が見え、`< /dev/null` を付けないと入力を待って止まったままになります。
Q. どう打ちますか。
openssl s_client -connect <host>:443 -servername <host> — 角括弧は省いてよい部分です。
Q. よく使うオプションはいくつですか。
ここにまとめたのは6個です。全部は man openssl にあります。このコマンドはネットワークの仲間です。
関連するコマンド
man ページ: man openssl-s_client