Skip to content

Instantly share code, notes, and snippets.

@myaaaaa-chan
Created March 21, 2017 05:34
Show Gist options
  • Save myaaaaa-chan/24c4f8e10378a2a6d4130a8d8c52edcc to your computer and use it in GitHub Desktop.
Save myaaaaa-chan/24c4f8e10378a2a6d4130a8d8c52edcc to your computer and use it in GitHub Desktop.
SSL証明書の有効期限までの残り日数を取得する
#!/bin/sh
ssl_expiration_date=`openssl s_client -connect $1:443 < /dev/null 2> /dev/null | openssl x509 -text | grep Not | grep -v Before | awk '/Not After : / {print $4, $5, $6, $7, $8}'`
expiration_second=`date +%s --date="$ssl_expiration_date"`
now_second=`date +%s`
((diff_second=expiration_second-now_second))
expiration_remaining_day=$((diff_second/86400))
echo $expiration_remaining_day
@myaaaaa-chan
Copy link
Author

Usage: ./get-ssl-expiration-date.sh hoge.exsample

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment