Omniauth facebook authentication failure

I am using devise and omniauth for authentication. Wherever i click on
the facebook login button i get this warning msg.


warning: peer certificate won’t be verified in this SSL session


But now i get this error msg


OpenSSL::SSL::SSLError SSL_connect returned=1 errno=0 state=SSLv3 read
server certificate B: certificate verify failed


What am i doing wrong?


Routes.rb

get “/auth/:provider/callback” => “authentications#create”

In my config/initializers/omniauth.rb

Rails.application.config.middleware.use OmniAuth::Builder do
provider :twitter, ‘xxxx’, ‘xxxx’
provider :facebook, ‘appid’, ‘appsecret’,
{:scope=>‘publish_stream,email’}
end

In my authentications controller

def create

  omniauth = request.env["omniauth.auth"]

  #search if user has been authenticated and application has been

authorised
authenticate =
Authentication.find_by_provider_and_uid(params[‘provider’],
omniauth[‘uid’])

  #if user has signed in with that provider before, sign user in and

show the requested page
if authenticate
sign_in_and_redirect(:user, authenticate.user)
flash[:notice] = “Authentication successful!!”
#create new user
else

user = User.new
user.apply_omniauth(omniauth)

case omniauth['provider']
  when 'facebook'
    if user.save
      user.profile = Profile.new

user.profile.picture_url =

https://graph.facebook.com/“+omniauth[‘uid’]+”/picture

user.profile.location =

omniauth[‘extra’][‘user_hash’][‘location’][‘name’]

user.profile.gender = omniauth[‘extra’][‘user_hash’][‘gender’]

#save users profile
if user.profile.save
  flash[:notice] = "Signed in with "+omniauth['provider']

  #sign user in
  sign_in_and_redirect(:user, user)
end
    else
redirect_to root_url, :notice => "Authentication failed, please try

again!"
end

  when 'twitter'
    session[:omniauth] = omniauth.except('extra')
    redirect_to "#{root_url}confirm-email"
  end
 end   #close of if statement

end #close of method

In models/user

def apply_omniauth(omniauth)

case omniauth['provider']
  when 'facebook'

self.email = omniauth[‘user_info’][‘email’]
end

self.username = omniauth['user_info']['nickname'] if username.blank?
self.name = omniauth['user_info']['name'] if name.blank?

authentications.build(:provider=>omniauth['provider'],

:uid=>omniauth[‘uid’], :token =>(omniauth[‘credentials’][‘token’] rescue
nil))

end


Please is there anything am doing wrong. Because it was working
perfectly locally and even on my heroku host until it started giving me
this error message

My Application stack trace

/usr/lib/ruby/1.8/net/http.rb:586:in connect' /usr/lib/ruby/1.8/net/http.rb:586:inconnect’
/usr/lib/ruby/1.8/net/http.rb:553:in do_start' /usr/lib/ruby/1.8/net/http.rb:542:instart’
/usr/lib/ruby/1.8/net/http.rb:1035:in __request__' rest-client (1.6.1) lib/restclient/net_http_ext.rb:17:inrequest’
/usr/lib/ruby/1.8/net/http.rb:772:in get' faraday (0.6.1) lib/faraday/adapter/net_http.rb:49:incall’
faraday (0.6.1) lib/faraday/request/url_encoded.rb:14:in call' faraday (0.6.1) lib/faraday/request.rb:88:inrun’
faraday (0.6.1) lib/faraday/request.rb:28:in run' faraday (0.6.1) lib/faraday/connection.rb:170:inrun_request’
oauth2 (0.3.0) lib/oauth2/client.rb:56:in request' oauth2 (0.3.0) lib/oauth2/strategy/web_server.rb:15:inget_access_token’
oa-oauth (0.2.2) lib/omniauth/strategies/oauth2.rb:87:in
build_access_token' oa-oauth (0.2.2) lib/omniauth/strategies/facebook.rb:31:inbuild_access_token’
oa-oauth (0.2.2) lib/omniauth/strategies/oauth2.rb:66:in
callback_phase' oa-core (0.2.2) lib/omniauth/strategy.rb:54:incall!’
oa-core (0.2.2) lib/omniauth/strategy.rb:26:in call' oa-core (0.2.2) lib/omniauth/strategy.rb:59:incall!’
oa-core (0.2.2) lib/omniauth/strategy.rb:26:in call' oa-core (0.2.2) lib/omniauth/builder.rb:30:incall’
warden (1.0.3) lib/warden/manager.rb:35:in call' warden (1.0.3) lib/warden/manager.rb:34:incatch’
warden (1.0.3) lib/warden/manager.rb:34:in call' actionpack (3.0.3) lib/action_dispatch/middleware/best_standards_support.rb:17:incall’
actionpack (3.0.3) lib/action_dispatch/middleware/head.rb:14:in call' rack (1.2.2) lib/rack/methodoverride.rb:24:incall’
actionpack (3.0.3) lib/action_dispatch/middleware/params_parser.rb:21:in
call' actionpack (3.0.3) lib/action_dispatch/middleware/flash.rb:182:incall’
actionpack (3.0.3)
lib/action_dispatch/middleware/session/abstract_store.rb:149:in call' actionpack (3.0.3) lib/action_dispatch/middleware/cookies.rb:295:incall’
activerecord (3.0.3) lib/active_record/query_cache.rb:32:in call' activerecord (3.0.3) lib/active_record/connection_adapters/abstract/query_cache.rb:28:incache’
activerecord (3.0.3) lib/active_record/query_cache.rb:12:in cache' activerecord (3.0.3) lib/active_record/query_cache.rb:31:incall’
activerecord (3.0.3)
lib/active_record/connection_adapters/abstract/connection_pool.rb:353:in
call' actionpack (3.0.3) lib/action_dispatch/middleware/callbacks.rb:46:incall’
activesupport (3.0.3) lib/active_support/callbacks.rb:415:in
_run_call_callbacks' actionpack (3.0.3) lib/action_dispatch/middleware/callbacks.rb:44:incall’
rack (1.2.2) lib/rack/sendfile.rb:107:in call' actionpack (3.0.3) lib/action_dispatch/middleware/remote_ip.rb:48:incall’
actionpack (3.0.3)
lib/action_dispatch/middleware/show_exceptions.rb:46:in call' railties (3.0.3) lib/rails/rack/logger.rb:13:incall’
rack (1.2.2) lib/rack/runtime.rb:17:in call' activesupport (3.0.3) lib/active_support/cache/strategy/local_cache.rb:72:incall’
rack (1.2.2) lib/rack/lock.rb:11:in call' rack (1.2.2) lib/rack/lock.rb:11:insynchronize’
rack (1.2.2) lib/rack/lock.rb:11:in call' actionpack (3.0.3) lib/action_dispatch/middleware/static.rb:30:incall’
railties (3.0.3) lib/rails/application.rb:168:in call' railties (3.0.3) lib/rails/application.rb:77:insend’
railties (3.0.3) lib/rails/application.rb:77:in method_missing' passenger (3.0.0) lib/phusion_passenger/rack/request_handler.rb:96:inprocess_request’
passenger (3.0.0)
lib/phusion_passenger/abstract_request_handler.rb:513:in
accept_and_process_next_request' passenger (3.0.0) lib/phusion_passenger/abstract_request_handler.rb:274:inmain_loop’
passenger (3.0.0)
lib/phusion_passenger/rack/application_spawner.rb:205:in
start_request_handler' passenger (3.0.0) lib/phusion_passenger/rack/application_spawner.rb:170:insend’
passenger (3.0.0)
lib/phusion_passenger/rack/application_spawner.rb:170:in
handle_spawn_application' passenger (3.0.0) lib/phusion_passenger/utils.rb:479:insafe_fork’
passenger (3.0.0)
lib/phusion_passenger/rack/application_spawner.rb:165:in
handle_spawn_application' passenger (3.0.0) lib/phusion_passenger/abstract_server.rb:357:insend
passenger (3.0.0) lib/phusion_passenger/abstract_server.rb:357:in
server_main_loop' passenger (3.0.0) lib/phusion_passenger/abstract_server.rb:206:instart_synchronously’
passenger (3.0.0) lib/phusion_passenger/abstract_server.rb:180:in
start' passenger (3.0.0) lib/phusion_passenger/rack/application_spawner.rb:128:instart’
passenger (3.0.0) lib/phusion_passenger/spawn_manager.rb:253:in
spawn_rack_application' passenger (3.0.0) lib/phusion_passenger/abstract_server_collection.rb:132:inlookup_or_add’
passenger (3.0.0) lib/phusion_passenger/spawn_manager.rb:246:in
spawn_rack_application' passenger (3.0.0) lib/phusion_passenger/abstract_server_collection.rb:82:insynchronize’
passenger (3.0.0)
lib/phusion_passenger/abstract_server_collection.rb:79:in synchronize' passenger (3.0.0) lib/phusion_passenger/spawn_manager.rb:244:inspawn_rack_application’
passenger (3.0.0) lib/phusion_passenger/spawn_manager.rb:137:in
spawn_application' passenger (3.0.0) lib/phusion_passenger/spawn_manager.rb:275:inhandle_spawn_application’
passenger (3.0.0) lib/phusion_passenger/abstract_server.rb:357:in
__send__' passenger (3.0.0) lib/phusion_passenger/abstract_server.rb:357:inserver_main_loop’
passenger (3.0.0) lib/phusion_passenger/abstract_server.rb:206:in
`start_synchronously’
passenger (3.0.0) helper-scripts/passenger-spawn-server:99