Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'open-uri'
content = nil
puts "Valid cert:"
open("https://www.wesabe.com") { |s| content = s.read }
puts " got #{content.length} bytes"
puts "Invalid cert: "
open("https://google.com") { |s| content = s.read }
puts " got #{content.length} bytes"
# Output:
#
# Valid cert:
# got 12199 bytes
# Invalid cert:
# /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/openssl/ssl.rb:123:in `post_connection_check': hostname was not match with the server certificate (OpenSSL::SSL::SSLError)
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment