Self-signed certificate verification

Hi there!

I am a newbie to Ruby language and looking forward to study and use in
for my routine tasks.

For now, I am trying to write a small script, which communicates with
some API using REST.

I found a pretty and nice gem for such a purpose, ‘rest-client’.

However, my small test code is unable to connect because of SSL
certificate verification. The certificate is self-signed itself.

The code:

#! /usr/bin/ruby

require ‘rest-client’’ , {:params
=> {:id => 50, ‘foo’ => ‘bar’},:verify_ssl => false}

And it returns:

$:~/ruby$ ./verifier.rb
rescue in transmit': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (RestClient::SSLCertificateNotVerified) from /usr/lib/ruby/gems/1.9.1/gems/rest-client-1.8.0/lib/restclient/request.rb:350:intransmit’
execute' from /usr/lib/ruby/gems/1.9.1/gems/rest-client-1.8.0/lib/restclient/request.rb:41:inexecute’
post' from ./verifier.rb:6:in

I have tried before writing here:

tried to pass it like this:
:verify_ssl => OpenSSL::SSL::VERIFY_NONE
tried to pass it like it is in the code now:
:verify_ssl => false

During surfing, I have found that actually key and pem file can be
included to request and everyting should be ok, but the problem arises
in case such a script should be used on several systems (e.g. I have to
change these files every time I launch the script).

Thanks anyway :slight_smile:


As far, as I understand, the issue is not rest-client itself, but the
libraries (gems), on which the client relies (net/http --> somewhat -->

The next solution works for me:

resource =
:verify_ssl => OpenSSL::SSL::VERIFY_NONE )

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs