OpenSSL::SSL::SSLError: certificate verify failed open-uri

I wrote a web-crawler today for one of my other projects, and ran into the above problem “OpenSSL::SSL::SSLError: certificate verify failed”, well I was just collecting websites and didn’t really care about the validity of SSL certificates, so I just wanted a quick fix.

Here it is:

require ‘openssl’
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE

Essentially, I just change the constant for VERIFY PEER to the Value of VERIFY NONE, pretty sneaky :-) , and no real work required.

3 Responses

  1. You are a life saver!

  2. Nice, this helped me too. I did get a warning about the already initialized constant, though, so I did this:

    module OpenSSL
    module SSL
    remove_const :VERIFY_PEER
    end
    end
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE

  3. This was very helpful in pointing me in the right direction. After some experimenting I’ve found this code to disable HTTPS verification without any warnings or overriding any constants.

    http = Net::HTTP.new(’secure.somehost.com’, 443)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
    response = http.get(“/secured/page”)

    Thanks again, I never would have found this without reading your post!

Leave a Reply

You must be logged in to post a comment.