Created
March 15, 2011 23:58
-
-
Save justincase/871758 to your computer and use it in GitHub Desktop.
Net HTTPS without callback
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/http' | |
require 'net/https' | |
require 'uri' | |
url = URI.parse("https://github.com/") # OK | |
#url = URI.parse("https://etutorials.org/") # Hostname mismatch | |
http = Net::HTTP.new(url.host, url.port) | |
http.use_ssl = true | |
http.verify_mode = OpenSSL::SSL::VERIFY_PEER | |
request = Net::HTTP::Get.new(url.path) | |
response = http.request(request) | |
# Result on both Mac OS 10.6.6 and Ubuntu 10.04.1 LTS: | |
=> OpenSSL::SSL::SSLError: hostname was not match with the server certificate | |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment