How to bypass SSL certificate verification in open-uri?

后端 未结 7 1178
無奈伤痛
無奈伤痛 2020-12-02 12:30

I try to access a file with open-uri over an https connection. Unfortunately somethings wrong with the certificate, I get a certificate verify failed error. I can\'

7条回答
  •  忘掉有多难
    2020-12-02 12:43

    A weak but controlled way is

    class XMLRPC::Client
     # WEAK: Enrich the Client with a method for disabling SSL VERIFICATION
     # See /usr/lib/ruby/1.9.1/xmlrpc/client.rb:324
     # Bad hack but it works
     def disableSSLVerification
       @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
       warn "Proxyman SSL Verification disabled"
     end
    end
    

    Then you simply call

    client.disableSSLVerification()
    

提交回复
热议问题