Forum: Ruby GET HTTPS request with Ruby 2.3.0

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
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
This topic is locked and can not be replied to.