Skip to content

Instantly share code, notes, and snippets.

@dissolve
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dissolve/a6b9147f142cfb04812e to your computer and use it in GitHub Desktop.
Save dissolve/a6b9147f142cfb04812e to your computer and use it in GitHub Desktop.
GWG's SSL error testing in ruby
require 'net/http'
uris = [
URI('https://www.google.com/'), #server with SSL
URI('https://david.shanske.com/'), #server with SNI (that isn't the default)
URI('https://ben.thatmustbe.me/') #server with SNI (that is the default)
]
connections = uris.map {|uri| Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https')}
requests = uris.map {|uri| Net::HTTP::Get.new uri}
0.upto(uris.length - 1) do |idx|
begin
connections[idx].request requests[idx]
puts "connect #{connections[idx].address} OK"
rescue => e
puts "Error on connection to #{connections[idx].address} before timeout: #{e.message}"
puts "Exiting as this does not prove anything"
exit
end
end
sleep 300
0.upto(uris.length - 1) do |idx|
begin
connections[idx].request requests[idx]
puts "reconnect #{connections[idx].address} OK"
rescue => e
puts "Error on reconnection to #{connections[idx].address} after timeout: #{e.message}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment