我使用Authlogic-Connect第三方登录。在运行适当的迁移后,Twitter/谷歌/yahoo登录似乎工作正常,但facebook登录抛出异常:

SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

开发日志显示

OpenSSL::SSL::SSLError (SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed):
  app/controllers/users_controller.rb:37:in `update'

请建议. .


当前回答

这可能是损坏/无效SSL证书的问题。在mac上可以使用此命令更新SSL证书:

rvm osx-ssl-certs update all

其他回答

OSX的解决方案:

安装最新的RVM稳定版本

rvm get stable

使用RVM命令自动解析证书

rvm osx-ssl-certs update all

如果你在OS X上使用RVM,你可能需要运行这个:

rvm osx-ssl-certs update all

更多信息请访问:http://rvm.io/support/fixing-broken-ssl-certificates

完整的解释如下:https://github.com/wayneeseguin/rvm/blob/master/help/osx-ssl-certs.md


更新

在Ruby 2.2上,你可能需要从源代码重新安装Ruby来解决这个问题。以下是如何(将2.2.3替换为Ruby版本):

rvm reinstall 2.2.3 --disable-binary

感谢https://stackoverflow.com/a/32363597/4353和伊恩·康纳。

OS x 10.8。x与Homebrew:

brew install curl-ca-bundle
brew list curl-ca-bundle
cp /usr/local/Cellar/curl-ca-bundle/1.87/share/ca-bundle.crt /usr/local/etc/openssl/cert.pem

只是因为对我有用的说明略有不同,我想我补充一下我的意见:

我在OS X Lion和使用macports和rvm

我安装了curl-ca-bundle:

sudo port install curl-ca-bundle

然后我调整了我的omniauth配置如下:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :google_oauth2, APP_CONFIG['CONSUMER_KEY'], APP_CONFIG['CONSUMER_SECRET'],
           :scope => 'https://www.google.com/m8/feeds https://www.googleapis.com/auth/userinfo.profile',
           :ssl => {:ca_path => "/share/curl/curl-ca-bundle.crt"}
end

然后,正如这篇博客文章所建议的,

“如何治愈Net::HTTP的风险默认HTTPS行为”

您可能需要安装always_verify_ssl_certificates gem,该gem允许您为ca_file设置默认值。