Created
October 17, 2012 22:13
-
-
Save bithive/3908667 to your computer and use it in GitHub Desktop.
SSL Certificate Expiration
This file contains 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
#!/usr/bin/env ruby | |
require 'date' | |
certs = [] | |
regex = /([\w\-\.]+):\s+Not After : (.+)/ | |
today = Date.today | |
%x[grep -H 'Not After' #{ARGV.shift}].each_line do |line| | |
data = regex.match line | |
cert = data[1] | |
next if certs.include? cert | |
certs << cert | |
date = Date.strptime data[2], "%b %e %H:%M:%S %Y %Z" | |
days = date - today | |
next if days > 7 or days < 0 | |
puts "#{cert} will expire in #{days} days!" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment