Skip to content

Instantly share code, notes, and snippets.

@djfpaagman
Created August 8, 2014 08:58
Show Gist options
  • Save djfpaagman/f9293ed600885a53c3b0 to your computer and use it in GitHub Desktop.
Save djfpaagman/f9293ed600885a53c3b0 to your computer and use it in GitHub Desktop.
SSL certificate checker
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