Search code examples
rubysslxml-rpc

How can I make ruby's xmlrpc client ignore SSL certificate errors?


When access an XML-RPC service using xmlrpc/client in ruby, it throws an OpenSSL::SSL::SSLError when the server certificate is not valid. How can I make it ignore this error and proceed with the connection?


Solution

  • Turns out it's like this:

    xmlrpc = ::XMLRPC::Client.new("foohost")
    xmlrpc.instance_variable_get(:@http).instance_variable_set(:@verify_mode, OpenSSL::SSL::VERIFY_NONE)
    

    That works with ruby 1.9.2, but clearly is poking at internals, so the real answer is "the API doesn't provide such a mechanism, but here's a hack".