Created
March 21, 2017 05:34
-
-
Save myaaaaa-chan/24c4f8e10378a2a6d4130a8d8c52edcc to your computer and use it in GitHub Desktop.
SSL証明書の有効期限までの残り日数を取得する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: ./get-ssl-expiration-date.sh hoge.exsample