-
-
Save luislavena/96b7d47bfb6803a9b881 to your computer and use it in GitHub Desktop.
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/https" | |
require "openssl" | |
store = OpenSSL::X509::Store.new | |
ssl_cert_glob = | |
File.expand_path "../lib/rubygems/ssl_certs/*.pem", __FILE__ | |
Dir.glob(ssl_cert_glob).each do |ssl_cert| | |
store.add_file ssl_cert | |
end | |
hosts = %w( | |
d2chzxaqi4y7f8.cloudfront.net | |
rubygems.org | |
s3.amazonaws.com | |
staging.rubygems.org | |
) | |
hosts.each do |host| | |
puts "Testing #{host}..." | |
begin | |
http = Net::HTTP.new(host, 443) | |
http.use_ssl = true | |
http.verify_mode = OpenSSL::SSL::VERIFY_PEER | |
http.cert_store = store | |
http.head('/') | |
rescue Errno::ENOENT | |
warn "#{host} seems offline, I can't tell whether ssl would work." | |
rescue OpenSSL::SSL::SSLError => e | |
# Only fail for certificate verification errors | |
if e.message =~ /certificate verify failed/ | |
warn "#{host} is not verifiable using the included certificates. Error was: #{e.message}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Error: