Vivek
Vivek

Reputation: 621

SSL Error OmniAuth in Ruby on Rails

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):

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?

Upvotes: 1

Views: 829

Answers (2)

jasin_89
jasin_89

Reputation: 2001

Hi Vivek I resolve this issue on windows 7, you can get certificate from here: https://gist.github.com/fnichol/867550

So location for this certificate will be C:\RailsInstaller\cacert.pem

Full image: config\initializers\omniauth.rb

OmniAuth.config.logger = Rails.logger

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :facebook, '4545454545fgdfg','545fg45fdh4f5d4gh5fd4h5fd4h5fd4h',
  {:scope => '', :client_options => { :ssl => { :ca_file => 'C:\RailsInstaller\cacert.pem'}}} 
end

Upvotes: 0

Pepa Chmel
Pepa Chmel

Reputation: 351

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

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

thanks to this posts:

Upvotes: 1

Related Questions