Created
November 16, 2011 06:50
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("/") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wish set_default_paths returned self...