0

Why we are getting this error when trying to make connection with Salesforce rest API through Faraday gem using ROR?

Faraday::Error::ConnectionFailed:
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
tomrozb
  • 25,773
  • 31
  • 101
  • 122
Ajay Gupta
  • 192
  • 1
  • 12
  • Please provide some code which causes the problem. The more information you provide, the easier it will be to help you identify the problem, and fix it. – Paweł Dawczak Mar 10 '15 at 11:23
  • There is a similar question here: http://stackoverflow.com/questions/10775640/omniauth-facebook-error-faradayerrorconnectionfailed – Amr Arafat Mar 10 '15 at 11:55
  • Code is working absolutely fine on application deployed on Heroku but it is not working on my local desktop – Ajay Gupta Mar 10 '15 at 18:20

1 Answers1

1

Faraday requires a valid root certificate to establish a connection.

If you're on a Windows machine, install the certificate with these instructions: https://gist.github.com/867550

For Mac, perform the following:

sudo port install curl-ca-bundle

Next, in your Faraday request, include this line immediately above where you actually send your request (e.g. https.request_get('/foo')):

https.ca_file = '/opt/local/share/curl/curl-ca-bundle.crt'

This will tell the http object Faraday uses to include the certificate in its request. If your system spits out an error, you may have to adjust the inclusion based on the file's location in your system.

All in all, your request will look something like this:

require 'net/https'
https = Net::HTTP.new('encrypted.google.com', 443)
https.use_ssl = true
https.ca_file = '/opt/local/share/curl/curl-ca-bundle.crt' if File.exists('/opt/local/share/curl/curl-ca-bundle.crt') # Mac OS X
https.request_get('/foo')
Collin Graves
  • 2,207
  • 15
  • 11