Error returning RestClient.get certificate

I am trying to get to the internal testing API server using RestClient and Ruby v. 2.2.1.

This is essentially the code:

url = "https://10.10.0.10/thing/i/want/to/get"
header = {
      :content_type => "application/json",
      :"x-auth-token" => "testingtoken"
  }
response = RestClient.get url, header

This is the error message I get:

SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (RestClient::SSLCertificateNotVerified)

If I read this right, it looks like Ruby was unable to accept the SSL security certificate. This call works in the Postman application for Chrome, but for it to work, I have to click the URL in Chrome itself and accept that the connection is not safe (but still), and THEN it will work in the postman.

Is there a way to ignore certificate errors and continue anyway in Ruby?

+4
source share
2 answers

Try using #execute(&block)with verify_sslinstalled on false.

:verify_ssl ssl, - OpenSSL::SSL::VERIFY_*, - OpenSSL::SSL::VERIFY_PEER

url = "https://10.10.0.10/thing/i/want/to/get"
headers = {
  :content_type => "application/json",
  :"x-auth-token" => "testingtoken"
}

RestClient::Request.execute(
  :url => url, 
  :method => :get, 
  :headers => headers,
  :verify_ssl => false
)

.: http://www.rubydoc.info/github/rest-client/rest-client/RestClient/Request#execute-instance_method


RVM: https://toadle.me/2015/04/16/fixing-failing-ssl-verification-with-rvm.html

Github : - RVM , openssl, /etc/openssl .

, , , , : rvm install 2.2.0 --disable-binary

+5

rest-client , CA . false :verify_ssl :ssl_ca_file :ssl_ca_path :ssl_cert_store, .

.

, :verify_ssl false:

url = "https://10.10.0.10/thing/i/want/to/get"
header = {
      :content_type => "application/json",
      :"x-auth-token" => "testingtoken"
}
resource = RestClient::Resource.new(
  url,
  headers: header,
  verify_ssl: false
)

response = resource.get

, , https://badssl.com/. irb.

response = RestClient::Resource.new(
 'https://self-signed.badssl.com/',
  :verify_ssl =>  false
).get
0

All Articles