Skip to content

Instantly share code, notes, and snippets.

@DriftwoodJP
Created July 19, 2017 02:18
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 DriftwoodJP/5e04d7c5bda0a2efc95560b9887f6abf to your computer and use it in GitHub Desktop.
Save DriftwoodJP/5e04d7c5bda0a2efc95560b9887f6abf to your computer and use it in GitHub Desktop.
Using Net::HTTP to the HTTPS url
require 'openssl'
require 'net/http'
https = Net::HTTP.new('www.google.co.jp', 443) # address, port
https.use_ssl = true
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
# https.verify_mode = OpenSSL::SSL::VERIFY_PEER
# https.ca_file = '/etc/ssl/cert.pem'
https.start do
response = https.get('/') # path
puts response.body
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment