非対話型(スクリプトから)opensslへのSSL / tls接続を確認するには?

非対話型(スクリプトから)opensslへのSSL / tls接続を確認するには?

私が実行したとき:

openssl s_client -connect google.com:443
openssl s_client -connect government.ru:443

opensslこれは私に貴重な出力を提供しますが、次のことができるように接続を閉じて、整数の終了コード(別の)を返して終了したいと思います。

echo "Domain?";read d
openssl s_client -connect "$d":443

if [[ "$?" -eq 0 ]]; then
  echo "Encrypted"; do_something
else 
  echo "Plain."; do_something_else
fi

ベストアンサー1

s_clientQコマンドを識別してください。openssl ドキュメント:

Q:  End the current SSL connection and exit.
printf "Q" | openssl s_client -connect google.com:443

または:

echo | openssl s_client -connect google.com:443

または:

openssl s_client -connect google.com:443 <<< "Q"

おすすめ記事