使用 Koala 和 Devise & 获取 SSL 错误Rails 3 应用程序中的 OmniAuth

发布于 2024-11-09 16:20:38 字数 904 浏览 4 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不及他 2024-11-16 16:20:38

从 Koala 存储库 https://github.com/arsduo/koala

您可以在 Koala 初始值设定项中设置此选项,该初始值设定项将设置此选项全球

/config/initializers/koala.rb

Koala.http_service.http_options = {
  :ssl => { :ca_path => "/etc/ssl/certs" }
}

From the Koala repo https://github.com/arsduo/koala

You can set this in a Koala initializer which will set this option globally

/config/initializers/koala.rb

Koala.http_service.http_options = {
  :ssl => { :ca_path => "/etc/ssl/certs" }
}
漫雪独思 2024-11-16 16:20:38

正如我在此线程中发现的,您可以在环境文件中设置选项(或在使用 gem 的类)以下选项:

Koala.http_service.ca_file = '/path/to/some/ca-certificate.crt'

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:

Koala.http_service.ca_file = '/path/to/some/ca-certificate.crt'
不…忘初心 2024-11-16 16:20:38

我发现这个解决方案很有帮助:将其放入您的环境配置文件中

(Koala::HTTPService.http_options[:ssl] ||= {})[:ca_path] =
'/path/to/ca/folder' (Koala::HTTPService.http_options[:ssl] ||=
{})[:ca_file] = '/path/to/ca/file'

您可以通过输入获取路径

openssl版本-a

并从结果源中提取路径


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

(Koala::HTTPService.http_options[:ssl] ||= {})[:ca_path] =
'/path/to/ca/folder' (Koala::HTTPService.http_options[:ssl] ||=
{})[:ca_file] = '/path/to/ca/file'

you can get the path by typing

openssl version -a

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文