Created
June 7, 2016 16:11
-
-
Save sonsongithub/07ac934fe7c23b796fcb3cbd28cef91b to your computer and use it in GitHub Desktop.
SSLの証明書の期限をJSONで書き出すコード
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
| require 'json' | |
| require 'date' | |
| r = [] | |
| hosts = [] | |
| hosts.each{|host| | |
| if`sudo openssl x509 -in /etc/letsencrypt/live/#{host}/fullchain.pem -noout -dates` =~ /notAfter=(.+?)$/ | |
| entry = {} | |
| entry[:host] = host | |
| entry[:expireDate] = $1 | |
| expireDate = Date.parse($1) | |
| today = Date::today | |
| entry[:remainingDays] = (expireDate - today).to_i | |
| r.push(entry) | |
| end | |
| } | |
| json = {} | |
| json[:data] = r | |
| json[:lastUpdate] = Time.now.to_s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment