Forum: Ruby Ruby XMLRPC OpenSSL::SSL::SSLError

Posted by Mohammed Yasin Rahman (Guest)
on 2012-11-23 16:01
(Received via mailing list)
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.
Posted by Hassan Schroeder (Guest)
on 2012-11-23 16:08
(Received via mailing list)
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/")
>
> 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)

It's not an "error"; try the above URL in a browser, and you'll see that
the cert is self-signed...
Posted by Mohammed Yasin Rahman (Guest)
on 2012-11-23 16:27
(Received via mailing list)
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

How to solve it? And why it works with python?
Posted by Hassan Schroeder (Guest)
on 2012-11-23 16:44
(Received via mailing list)
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

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 :-)

What is the environment that's giving you this message?
Posted by Mohammed Yasin Rahman (Guest)
on 2012-11-23 16:52
(Received via mailing list)
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
Posted by Hassan Schroeder (Guest)
on 2012-11-23 16:57
(Received via mailing list)
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

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.
Posted by Mohammed Yasin Rahman (Guest)
on 2012-11-23 17:02
(Received via mailing list)
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/")
 => #<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.
Posted by Hassan Schroeder (Guest)
on 2012-11-23 17:12
(Received via mailing list)
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:

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

What changed between when you got the error and this result?
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.