Ruby on Rails中的SSL错误OmniAuth [英] SSL Error OmniAuth in Ruby on Rails

查看:87
本文介绍了Ruby on Rails中的SSL错误OmniAuth的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经读到了很多有关此错误的信息,尤其是在OmniAuth for Rails 3中.我有几个问题,因为当前我被卡在它上面.

I've read a lot about this error especially in OmniAuth for Rails 3. I have a few questions because currently I'm stuck on it.

The consensus in this post was that it couldn't reference the certs properly. My first question is this (I'm using Windows 7 to preface the question):

我将开始在硬盘驱动器的确切位置找到证书吗?我使用RailsInstaller来安装Rails 3,并且我能找到的唯一靠近该位置的地方是"Git"中,其中有一个带有ca-path文件的"cert"目录.但是,大多数人的参考是这个"/etc/certs/"之类的东西(基本上是一个相对的URL).我的问题是在哪里引用父目录?这可能非常简单,但我不知道.是我在C:/目录中的RailsInstaller文件夹吗?

Where exactly in my hard drive would I begin to look to find the certs? I used RailsInstaller to install Rails 3 and the only thing that I can find that is close to that location is in "Git" where there is a "cert" directory with the ca-path file. However, the reference that most people have is this "/etc/certs/" or something (basically a relative url). My question is where is the parent directory from which this is referenced? It may be extremely simple but I just don't know. Would it be my RailsInstaller folder in the C:/ directory?

推荐答案

在我的config \ initializers \ devise.rb

In my config\initializers\devise.rb

require "omniauth-facebook"

if RbConfig::CONFIG["host_os"] =~ /mingw|mswin/
    ca_file = File.expand_path Rails.root.join("config", "cacert.pem")

    ssl_options = {}
    ssl_options[:ca_path] = '/etc/ssl/certs' if Rails.env.staging?
    ssl_options[:ca_file] = ca_file

    config.omniauth :facebook, "APP_ID", "APP_SECRET", # "APP_ID", "APP_SECRET" your got from facebook app registration
        :client_options => {:ssl => ssl_options}
else
    config.omniauth :facebook, "APP_ID", "APP_SECRET"
end

来自 http://curl.haxx.se/ca/

文件cacert.pem到您的Rails应用程序配置目录

file cacert.pem from http://curl.haxx.se/ca/ put to your rails app config directory

感谢这篇文章:

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