Skip to content

Instantly share code, notes, and snippets.

@bithive
Created October 17, 2012 22:13
Show Gist options
  • Save bithive/3908667 to your computer and use it in GitHub Desktop.
Save bithive/3908667 to your computer and use it in GitHub Desktop.
SSL Certificate Expiration
#!/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