Skip to content

Instantly share code, notes, and snippets.

@CharlieSu

CharlieSu/ssl.rb Secret

Created July 11, 2012 14:14
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 CharlieSu/cb3ae1e4a7bfa60cc5a1 to your computer and use it in GitHub Desktop.
Save CharlieSu/cb3ae1e4a7bfa60cc5a1 to your computer and use it in GitHub Desktop.
require 'net/http'
require 'net/https'
require 'uri'
url = "https://yahoo.com"
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.use_ssl = uri.scheme == 'https' ? true : false
begin
resp, data = http.get(uri.path, nil)
puts "Response #{resp.code} #{resp.message}: #{resp.body}"
rescue Exception => e
puts e.inspect
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment