google-api-ruby-client: certificate verify failed (Faraday::SSLError)
OSX 10.10.3, Ruby 2.2.1p85, gem version 0.9.pre1
Full error:
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/http.rb:923:in connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (Faraday::SSLError) from /Users/asmith/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/http.rb:923:inblock in connect’
from /Users/asmith/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/timeout.rb:74:in timeout' from /Users/asmith/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/http.rb:923:inconnect’
from /Users/asmith/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/http.rb:863:in do_start' from /Users/asmith/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/http.rb:852:instart’
from /Users/asmith/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/http.rb:1375:in request' from /Users/asmith/.rvm/gems/ruby-2.2.1/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:82:inperform_request’
from /Users/asmith/.rvm/gems/ruby-2.2.1/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:40:in block in call' from /Users/asmith/.rvm/gems/ruby-2.2.1/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:87:inwith_net_http_connection’
from /Users/asmith/.rvm/gems/ruby-2.2.1/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:32:in call' from /Users/asmith/.rvm/gems/ruby-2.2.1/gems/faraday-0.9.1/lib/faraday/request/url_encoded.rb:15:incall’
from /Users/asmith/.rvm/gems/ruby-2.2.1/gems/signet-0.6.1/lib/signet/oauth_2/client.rb:957:in fetch_access_token' from /Users/asmith/.rvm/gems/ruby-2.2.1/gems/signet-0.6.1/lib/signet/oauth_2/client.rb:983:infetch_access_token!’
from run.rb:17:in `<main>’
I am able to hotwire with this at the top:
require ‘openssl’ OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
…but that kinda sucks.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 5
- Comments: 38 (1 by maintainers)
FWIW, this is what worked for me:
cert_path = Gem.loaded_specs[‘google-api-client’].full_gem_path+‘/lib/cacerts.pem’ ENV[‘SSL_CERT_FILE’] = cert_path
A system wide solution would be this (for Yosemite and Ruby 2.2.1):
Downloading this http://curl.haxx.se/ca/cacert.pem, and saving it replacing
/usr/local/etc/openssl/cert.pem. Addexport SSL_CERT_FILE=/usr/local/etc/openssl/cert.pemto your.bash_profile. All net::http will pickup onENV['SSL_CERT_FILE'].RVM and ruby seems to have an outdated CA cert.
I have used in this way and it worked for me. connection = Faraday.new(“http://example.com”) connection.ssl.verify_mode = OpenSSL::SSL::VERIFY_NONE
I fix the error with
rvm reinstall ruby-2.1.5 --with-openssl-dir=/usr/localI was getting this issue on my Mac too.
brew updateand thenbrew upgrade opensslfixed it.upgrading ruby to 2.3.0 solved it for me as well
Nice explanation given here : https://toadle.me/2015/04/16/fixing-failing-ssl-verification-with-rvm.html
Because pre-build version doesn’t distinguish between different OS X versions (has wrong paths hardcoded). Newer OS X has a different SSL subsystem.
@schanami helped me rvm reinstall 2.2.2 --disable-binary thx
@sqrrrl Updating
openssldidn’t solve this problem for me. I have to setSSL_CERT_FILEto the bundledcacerts.pemfile.FWIW switching to a different (open) wifi network may help.
I’m no expert in networking/certificates but I recently ran into the same issue when I was trying to hit a Ruby backend with an OAuth callback. My environment was fine (macOS Sierra 10.12.6 + Docker Ruby 2.3.1 base image) and my local certificates were alright but the secured network I was on was modifying certificates to make it unfriendly for the Ruby app.
Just wanted to mention in case someone exhausted all the local options like me and was still getting:
Faraday::SSLError (SSL_connect returned=1 errno=0 state=error: certificate verify failed)Using OS X 10.10.5 and Ruby 2.3.1 via RBENV, the issue was fixed by performing steps #2 and #3 from @bryszard’s response.
Thank you @sony-mathew-fd. The solution pointed by you (https://toadle.me/2015/04/16/fixing-failing-ssl-verification-with-rvm.html) helped a lot. What I had to do:
rvm reinstall 2.2.0 --disable-binary/usr/local/etc/openssl/cert.pemexport SSL_CERT_FILE=/usr/local/etc/openssl/cert.pemto.bash_profileI encountered this problem while I was using
google-cloud-rubygem and Ruby 2.4.0.RVM > 1.9.1 comes with the method for updating certificates:
rvm osx-ssl-certs update allcredits: http://railsapps.github.io/openssl-certificate-verify-failed.html
The solution for me on OS X 10.11.4, Ruby 2.1.2 was running
rvm reinstall ruby-2.1.2 --disable-binaryor switching to 2.3.0. This is perplexing as colleagues who had the app already set up on their dev machines and have the same OS and Ruby versions had this problem in 2015 but could solve it by simply downloading http://curl.haxx.se/ca/cacert.pem and ensuring that Ruby 2.1.2 was installed with the--with-openssl-dir=$rvm_path/usrflag. Can anyone can explain why installing Ruby from sources solves the problem?To clarify, none of the following solved the issue:
ENV['SSL_CERT_FILE'] = '/usr/local/etc/openssl/cert.pem') or with a system environment variablervm requirementsrvm remove 2.1.2 && rvm pkg install openssl && rvm install 2.1.2 --with-openssl-dir=$rvm_path/usrWith rvm (with Ruby 2.2.3 installed), on OS X, what fixed it for me was:
Just in case anyone still facing issue… upgrading to Ruby 2.3.0 helped me. (was in 2.2.3)
Here is what worked for me:
I’m running OS X 10.11.1, Ruby 2.2.1, openssl 1.0.2d_1
Upgrading to Ruby 2.2.3 fixed the problem.