Skip to content

Instantly share code, notes, and snippets.

@ganta
Created April 16, 2015 08:28
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 ganta/1e1edadce453d0ba34ed to your computer and use it in GitHub Desktop.
Save ganta/1e1edadce453d0ba34ed to your computer and use it in GitHub Desktop.
RubyでのHTTPS接続のサンプル
require 'net/http'
require 'openssl'
host = 'www.google.com'
https = Net::HTTP.new(host, 443)
#https.open_timeout = SYSTEM_TIMEOUT_SEC
#https.read_timeout = SYSTEM_TIMEOUT_SEC
https.use_ssl = true
https.verify_mode = OpenSSL::SSL::VERIFY_PEER
https.verify_depth = 5
#https.ca_file = '/path/to/cacert.pem'
https.start do |h|
res = h.get('/')
p res
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment