Forum: Ruby GET HTTPS request with Ruby 2.3.0

1057478e3cb6dc53aa4d46220dd9d189?d=identicon&s=25 Rub Rubinsky (rubinsky)
on 2017-02-09 21:58
Hi,

I'm stuck with an error when I try to do a get request.
Message:
`connect_nonblock': SSL_connect returned=1 errno=0 state=error:
certificate verify failed (OpenSSL::SSL::SSLError)

This was my code:

uri = URI(link)
Net::HTTP.start(uri.host, uri.port,
  :use_ssl => uri.scheme == 'https') do |http|
  request = Net::HTTP::Get.new uri

  response = http.request request # Net::HTTPResponse object
  puts response.body
end

Have anyone else gotten the same connection error before?

//EDIT:
Found my answer.
I needed to add:

require 'openssl'
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.