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’
RestClient.post
‘https://192.168.67.214/rest/Customer/update_payment_method/’ , {:params
=> {:id => 50, ‘foo’ => ‘bar’},:verify_ssl => false}
And it returns:
$:~/ruby$ ./verifier.rb
/usr/lib/ruby/gems/1.9.1/gems/rest-client-1.8.0/lib/restclient/request.rb:445:in
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:in
transmit’
from
/usr/lib/ruby/gems/1.9.1/gems/rest-client-1.8.0/lib/restclient/request.rb:176:in
execute' from /usr/lib/ruby/gems/1.9.1/gems/rest-client-1.8.0/lib/restclient/request.rb:41:in
execute’
from
/usr/lib/ruby/gems/1.9.1/gems/rest-client-1.8.0/lib/restclient.rb:69:in
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
ADD:
As far, as I understand, the issue is not rest-client
itself, but the
libraries (gems), on which the client relies (net/http → somewhat →
openssl?)