XML-RPC over SSL with Ruby and "warning: peer certificate won't be verified in this SSL session"

May 3, 2010

When using XML-RPC over SSL with Ruby, you may receive the following annoying warning:

                      warning: peer certificate won't be verified in this SSL session
                      

There is a very simple (but very poorly documented) fix for this. After instantiating your XMLRPC::Client object…

                      server = XMLRPC::Client.new3( ... )
                      

Add the following line:

                      server.instance_variable_get(:@http).instance_variable_get(:@ssl_context).instance_variable_set(:@verify_mode, OpenSSL::SSL::VERIFY_NONE)
                      

Now do your XML-RPC calls as usual:

                      result = server.call( ... )
                      
blog comments powered by Disqus