Skip to content

Instantly share code, notes, and snippets.

@bgreenlee
Created February 26, 2010 06:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bgreenlee/315482 to your computer and use it in GitHub Desktop.
Save bgreenlee/315482 to your computer and use it in GitHub Desktop.
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