Skip to content

Instantly share code, notes, and snippets.

@tmaher
Created November 14, 2012 03:16
Show Gist options
  • Select an option

  • Save tmaher/a4c08567afc01992a939 to your computer and use it in GitHub Desktop.

Select an option

Save tmaher/a4c08567afc01992a939 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'net/https'
require 'uri'
require 'openssl'
require 'socket'
host = "tlsdebugging.herokuapp.com"
ip = 'elb000016-256743859.us-east-1.elb.amazonaws.com'
port = 443
#ctx = OpenSSL::SSL::SSLContext.new :SSLv23_client
ctx = OpenSSL::SSL::SSLContext.new :TLSv1
errors = 0
runcount = ARGV[0].nil? ? 1000 : ARGV[0].to_i
completed = 0
begin
for i in 1..runcount
tcp_client = TCPSocket.new ip, port
ssl_client = OpenSSL::SSL::SSLSocket.new tcp_client, ctx
ssl_client.connect
ssl_client.write "GET / HTTP/1.1\r\nHost: #{host}\r\nConnection: close\r\n\r\n"
resp = ssl_client.read.split(/\r|\n/)
if resp[0] !~ /503/
$stdout.write "."
else
$stdout.write "X"
errors += 1
end
$stdout.flush
ssl_client.close
completed += 1
end
rescue Exception => e
puts e.inspect
end
puts "\n"
puts "#{errors} errors, #{completed} runs, #{100 * errors.fdiv(completed)}% fail"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment