使用 Koala 和 Devise & 获取 SSL 错误Rails 3 应用程序中的 OmniAuth
我正在使用 Devise/OmniAuth 和 Koala 构建 Rails 3 应用程序,并且收到以下 SSL 错误:
OpenSSL::SSL::SSLError in Users/omniauth callbacksController#facebook
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
导致此错误的代码是:
@graph = Koala::Facebook::GraphAPI.new(@token)
@friends = @graph.get_connections("me", "friends")
我正在使用 Devise 和 OmniAuth 来执行身份验证,这有效。然后,我获取返回的 facebook 令牌,并尝试将其与 Koala 一起使用,如上所示。这就是导致此错误的原因。
可能值得注意的是,我在 Devise & 中收到了同样的错误。最初是 OmniAuth。有几个关于此错误的主题,我能够通过设置 config/initialisers/devise.rb 来解决它,
config.omniauth :facebook, APPID, APPKEY, {:client_options => {:ssl => {:ca_file => "/opt/local/share/curl/curl-ca-bundle.crt"}}}
我猜测我需要为 Koala 提供类似的配置,以便它知道在哪里检索本地 ca_file.但我在文档中找不到任何关于如何执行此操作的指示。关于如何执行此操作或如何避免一般错误的任何想法?
我的开发环境是 OSX。
I'm building a Rails 3 app using Devise/OmniAuth, and Koala and I'm getting the following SSL error:
OpenSSL::SSL::SSLError in Users/omniauth callbacksController#facebook
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
The code that causes this error is:
@graph = Koala::Facebook::GraphAPI.new(@token)
@friends = @graph.get_connections("me", "friends")
I am using Devise with OmniAuth to perform authentication, which works. I then take the returned facebook token, and attempt to use it with Koala as shown above. That is what causes this error.
It's probably worth noting that I was receiving the same error with Devise & OmniAuth initially. There are a few topics about this error, and I was able to solve it, by setting up my config/initialisers/devise.rb with,
config.omniauth :facebook, APPID, APPKEY, {:client_options => {:ssl => {:ca_file => "/opt/local/share/curl/curl-ca-bundle.crt"}}}
I am guessing that I need to supply a similar configuration for Koala so that it knows where to retrieve the local ca_file. I can't find any indication of how to do so in the documentation though. Any ideas on how to do this, or how to avoid the error in general?
My dev environment is OSX.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从 Koala 存储库 https://github.com/arsduo/koala
您可以在 Koala 初始值设定项中设置此选项,该初始值设定项将设置此选项全球
From the Koala repo https://github.com/arsduo/koala
You can set this in a Koala initializer which will set this option globally
正如我在此线程中发现的,您可以在环境文件中设置选项(或在使用 gem 的类)以下选项:
As I found on this thread you can set your options in your environment file (or in the class where you're using the gem) the following option:
我发现这个解决方案很有帮助:将其放入您的环境配置文件中
您可以通过输入获取路径
并从结果源中提取路径
:
https://github.com/arsduo/koala/issues/130
https://github.com/technoweenie/faraday/wiki/Setting-up -SSL证书
I found this solution helpful: put this in your environment configuration file
you can get the path by typing
and extracting the path from the result
sources:
https://github.com/arsduo/koala/issues/130
https://github.com/technoweenie/faraday/wiki/Setting-up-SSL-certificates