Created
August 8, 2014 08:58
-
-
Save dennispaagman/f9293ed600885a53c3b0 to your computer and use it in GitHub Desktop.
SSL certificate checker
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
require 'net/http' | |
# hosts is an Array of hosts to be checked. For example: | |
hosts = ['www.springest.nl', 'www.springest.de', 'www.springest.com'] | |
hosts.each do |host| | |
http = Net::HTTP.new(host, 443) | |
http.use_ssl = true | |
req = Net::HTTP::Head.new('/') | |
begin | |
http.start { http.request(req) } | |
puts "#{host}: OK" | |
rescue Errno::ECONNREFUSED | |
puts "#{host}: Error: connection refused" | |
next | |
rescue OpenSSL::SSL::SSLError, SocketError => e | |
puts "#{host}: #{e.class}: #{e.message}" | |
next | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment