# plenty of people have had issues with the dreaded # # " certificate verify failed " # # error ruby someones barfs at you accessing https links via open-uri or # net/http # # you can find plenty of lame solutions to this on the intertubes # # http://www.google.com/search?q=ruby+certificate+verify+failed&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a # # but here is one that works without having to spin every connection yourself # and set intance variables - eg. it works for open-uri as well # # you'll want this code # def openssl_verifying_none(&block) verify_peer = OpenSSL::SSL::VERIFY_PEER verify_none = OpenSSL::SSL::VERIFY_NONE begin non_verbosely{ OpenSSL::SSL.send(:const_set, :VERIFY_PEER, verify_none) } return block.call ensure non_verbosely{ OpenSSL::SSL.send(:const_set, :VERIFY_PEER, verify_peer) } end end def non_verbosely(&block) verbose = $VERBOSE begin $VERBOSE = nil block.call ensure $VERBOSE = verbose end end # and then you simply wrap the operations giving you grief like so: # require 'open-uri' openssl_verifying_none do open(https_uri) do |socket| content = socket.read end end # bang. that's it.