【问题标题】:Getting SSL Error Using Koala with Devise & OmniAuth in a Rails 3 App在 Rails 3 应用程序中使用带有 Devise 和 OmniAuth 的 Koala 出现 SSL 错误
【发布时间】:2011-09-01 21:47:43
【问题描述】:

我正在使用 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")

我正在使用带有 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。

【问题讨论】:

  • 我已经使用 MiniFB (github.com/victorcoder/mini_fb) 作为考拉的替代品,到目前为止,我的运气更好。它至少返回数据而不给出 SSL 错误。

标签: ruby-on-rails-3 facebook devise omniauth koala


【解决方案1】:

来自考拉回购https://github.com/arsduo/koala

您可以在 Koala 初始化程序中设置此选项,该初始化程序将全局设置此选项

/config/initializers/koala.rb

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

【讨论】:

    【解决方案2】:

    As I found on this thread 您可以在您的环境文件(或您使用 gem 的类)中设置以下选项:

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

    【讨论】:

      【解决方案3】:

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

      (考拉::HTTPService.http_options[:ssl] ||= {})[:ca_path] = '/path/to/ca/folder' (考拉::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-certificates

      【讨论】:

        猜你喜欢
        • 2012-02-15
        • 1970-01-01
        • 1970-01-01
        • 2018-02-07
        • 1970-01-01
        • 2011-09-25
        • 2011-07-22
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多