Shreya
Shreya

Reputation: 63

SSL_connect returned=1 errno=0 state=error: certificate verify failed also I tried to install gem openssl but can't

require 'rubygems'
require 'httparty'

class myClass
  include HTTParty
  base_uri 'https://jsonplaceholder.typicode.com'

  def posts
    self.class.get('/users')
  end
end

Upvotes: 0

Views: 525

Answers (1)

Shreya
Shreya

Reputation: 63

So, I got this error. And the simplest solution to this is as below.

  1. Download cacert.pem file from this link http://curl.haxx.se/ca/cacert.pem

  2. So, I have installed my Ruby in D drive inside Railsinstaller folder likewise, "D:\RailsInstaller\Ruby2.3.3\lib\ruby\2.3.0\rubygems\ssl_certs" go to the directory where you have install ruby and got to this path "Ruby2.3.3\lib\ruby\2.3.0\rubygems\ssl_certs inside this save the cacert.pem file, make sure it is .pem file.

  3. Now, go to the environment.rb file in your rails application and save as below: ENV['SSL_CERT_FILE'] = "/your/file/path/cacert.pem"

and DONE!

Upvotes: 1

Related Questions