Omniauth Facebook错误 - Faraday :: Error :: ConnectionFailed [英] Omniauth Facebook Error - Faraday::Error::ConnectionFailed

查看:239
本文介绍了Omniauth Facebook错误 - Faraday :: Error :: ConnectionFailed的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



一旦我登录了Facebook,就可以在Facebook上关注Twitter Omniauth使用Omniauth,我得到这个错误:

  Faraday :: Error :: ConnectionFailed 
SSL_connect returned = 1 errno = 0状态= SSLv3读服务器证书B:证书验证失败

这是什么意思?



这是我的代码

  Rails.application.config.middleware.use OmniAuth ::生成器$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ 



$ / code $ >

我的代码实际上没有什么,所有我在sessionController中,我想使用to_yaml来查看request.env里面有什么

  class SessionsController< ApplicationController 
def create
raise request.env [omniauth.auth] to_yaml
end
end

如何解决法拉第错误?

解决方案

错误,因为Ruby找不到根证书来信任。



修复Windows: https://gist.github.com/867550



修复Apple / Linux: http://martinottenwaelter.fr/2010/12/ruby19-and-the-ssl-error/ <



以下是根据上述网站的Apple / Linux修复程序:



解决方案是安装包含Firefox使用的相同根证书的curl-ca-bundle端口:

  sudo port install curl-ca-bundle 

并告诉你的h ttps对象使用它:

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

请注意,如果您希望您的代码在Ubuntu上运行,则需要设置ca_path属性相反,使用默认证书位置/ etc / ssl / certs。



最后,这将在Mac OS X和Ubuntu上运行:

  require'net / https'
https = Net :: HTTP.new('encrypted.google.com',443)
https.use_ssl = true
https.verify_mode = OpenSSL :: SSL :: VERIFY_PEER
https.ca_path ='/ etc / ssl / certs'如果File.exists?('/ etc / ssl /证书)#Ubuntu
https.ca_file ='/opt/local/share/curl/curl-ca-bundle.crt'如果File.exists('/ opt / local / share / curl / curl-ca- bundle.crt')#Mac OS X
https.request_get('/')


(FYI: I'm following the Twitter Omniauth from railscast #241. I used Twitter successfully, now going onto Facebook)

As soon as I logged into Facebook using Omniauth, I get this error:

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

What does this mean?

This is my code

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :facebook, '<key from fb>', '<another key from fb>'
end

There's actually nothing much in my code, all I have is in the sessionController that I want to use to_yaml to see what's inside the request.env

class SessionsController < ApplicationController
    def create
        raise request.env["omniauth.auth"].to_yaml
    end
end

How do I solve the Faraday error?

解决方案

You are getting this error because Ruby cannot find a root certificate to trust.

Fix for Windows: https://gist.github.com/867550

Fix for Apple/Linux: http://martinottenwaelter.fr/2010/12/ruby19-and-the-ssl-error/ <--This site is now down.

Here is the Apple/Linux fix according the site above:

The solution is to install the curl-ca-bundle port which contains the same root certificates used by Firefox:

sudo port install curl-ca-bundle

and tell your https object to use it:

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

Note that if you want your code to run on Ubuntu, you need to set the ca_path attribute instead, with the default certificates location /etc/ssl/certs.

In the end, that’s what will work on both Mac OS X and Ubuntu:

require 'net/https'
https = Net::HTTP.new('encrypted.google.com', 443)
https.use_ssl = true
https.verify_mode = OpenSSL::SSL::VERIFY_PEER
https.ca_path = '/etc/ssl/certs' if File.exists?('/etc/ssl/certs') # Ubuntu
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('/')

这篇关于Omniauth Facebook错误 - Faraday :: Error :: ConnectionFailed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆