35
34

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

シェルでSSL証明書の有効期限を確認する

Posted at

意外とSSL証明書の有効期限をコマンドラインで取得する方法が見つかりにくかったので書いてみる。
運用担当さんが複数のSSL証明書の期限管理などを機械的に実施したい場合に便利かも。

opensslコマンドを使って以下の様にすると${DOMAIN}のSSLを${CERT}というファイル名で取得します。
次のdateコマンドは、処理しやすいように証明書期限の日付を取ってくる例です。

openssl s_client -connect ${DOMAIN}:443 </dev/null > ${CERT} 2>/dev/null
date +%Y%m%d --date="`openssl x509 -text -in ${CERT} | sed -e "/Not After/{s/^.* : //;p};d"`"
35
34
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
35
34

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?