Ruby XMLRPC OpenSSL::SSL::SSLError

Hi,

I am trying to connect an api using xmlrpc in ruby. When I run the following code:

  ret = XMLRPC::Client.new2("https://api2.top-hat.info/API/")

It gives me the following error:

  /Users/rahmanm/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:799:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)

On the other hand, the same call works for python. In python when I run the equivalent call:

  srv = xmlrpclib.Server("https://api2.top-hat.info/API/", allow_none = 1)
  
I can access the api.

Could you please tell me how to solve this ssl error in ruby.

···

--
Yasin

It's not an "error"; try the above URL in a browser, and you'll see that
the cert is self-signed...

···

On Fri, Nov 23, 2012 at 7:00 AM, Mohammed Yasin Rahman <Mohammed-Yasin.Rahman@lip6.fr> wrote:

        ret = XMLRPC::Client.new2("https://api2.top-hat.info/API/&quot;\)

It gives me the following error:

        /Users/rahmanm/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:799:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

twitter: @hassan

How to solve it? And why it works with python?

···

On Nov 23, 2012, at 4:08 PM, Hassan Schroeder <hassan.schroeder@gmail.com> wrote:

It's not an "error"; try the above URL in a browser, and you'll see that
the cert is self-signed…

--
Yasin

Though having said that, I tried your XMLRPC example here using
ruby-1.9.3-p286 and OpenSSL 0.9.8r 8 Feb 2011 and it worked fine
(i.e. no such error message).

Not sure what to think about that :slight_smile:

What is the environment that's giving you this message?

···

On Fri, Nov 23, 2012 at 7:26 AM, Mohammed Yasin Rahman <Mohammed-Yasin.Rahman@lip6.fr> wrote:

It's not an "error"; try the above URL in a browser, and you'll see that
the cert is self-signed…

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

twitter: @hassan

I am using ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.2.0] and OpenSSL 0.9.8r 8 Feb 2011 in OS X
If you want I can send you my entire script

···

On Nov 23, 2012, at 4:43 PM, Hassan Schroeder <hassan.schroeder@gmail.com> wrote:

Though having said that, I tried your XMLRPC example here using
ruby-1.9.3-p286 and OpenSSL 0.9.8r 8 Feb 2011 and it worked fine
(i.e. no such error message).

Not sure what to think about that :slight_smile:

What is the environment that's giving you this message?

You might try with the latest Ruby, then, because we're on the same
version of openssl... Other than that, I don't know why I wouldn't see
the same result here.

···

On Fri, Nov 23, 2012 at 7:50 AM, Mohammed Yasin Rahman <Mohammed-Yasin.Rahman@lip6.fr> wrote:

I am using ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.2.0]
and OpenSSL 0.9.8r 8 Feb 2011 in OS X

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

twitter: @hassan

When I use it in irb it gives me the following message:

1.9.3-p194 :003 > ret = XMLRPC::Client.new2("https://api2.top-hat.info/API/&quot;\)
=> #<XMLRPC::Client:0x007f8cac0859b8 @http_header_extra=nil, @http_last_response=nil, @cookie=nil, @host="api2.top-hat.info", @path="/API/", @proxy_host=nil, @proxy_port=nil, @use_ssl=true, @timeout=30, @port=443, @password=nil, @user=nil, @auth=nil, @http=#<Net::HTTP api2.top-hat.info:443 open=false>, @parser=nil, @create=nil>

Is it error or it means that the xmlrpc is working?

Thanks for your help.

···

On Nov 23, 2012, at 4:57 PM, Hassan Schroeder <hassan.schroeder@gmail.com> wrote:

You might try with the latest Ruby, then, because we're on the same
version of openssl... Other than that, I don't know why I wouldn't see
the same result here.

That's what I see, as well, and I assume that constitutes "working".

What changed between when you got the error and this result?

···

On Fri, Nov 23, 2012 at 8:01 AM, Mohammed Yasin Rahman <Mohammed-Yasin.Rahman@lip6.fr> wrote:

When I use it in irb it gives me the following message:

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

twitter: @hassan