Reputation: 192
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
Upvotes: 0
Views: 364
Reputation: 2257
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')
Upvotes: 1