Skip to content

Instantly share code, notes, and snippets.

@shugo
Created November 16, 2011 06:50
Show Gist options
  • Save shugo/1369468 to your computer and use it in GitHub Desktop.
Save shugo/1369468 to your computer and use it in GitHub Desktop.
how to stop warning: peer certificate won't be verified in this SSL session
require 'net/https'
http = Net::HTTP.new("example.com", 443)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
store = OpenSSL::X509::Store.new
store.set_default_paths
http.cert_store = store
# For Windows, use Net::HTTP#ca_file= instead of the above three lines as follows:
# http.ca_file = "/path/to/cacert.pem"
# Root certificates are available at http://curl.haxx.se/ca/cacert.pem
http.start {
response = http.get("/")
}
@knu
Copy link

knu commented Nov 16, 2011

http.cert_store = OpenSSL::X509::Store.new.tap { |store| store.set_default_paths }

Wish set_default_paths returned self...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment