OpenSSL :: SSL :: SSLError - SSL_connect返回= 1 errno = 0状态= SSLv3读取服务器证书B:证书验证失败

时间:2012-01-28 22:42:17

标签: ruby-on-rails ruby-on-rails-3

我收到此错误:

OpenSSL::SSL::SSLError

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

Rails.application.config.middleware.use OmniAuth::Builder do  
  provider :facebook, 'MY_APPID', 'SECRET', {:scope => 'publish_stream,email', :client_options => {:ssl => {:ca_path => "#{Rails.root}/config/cacert.pem"}}}
end

行动:

def callback
  session['fb_auth'] = request.env['omniauth.auth']
  session['fb_token'] = session['fb_auth']['credentials']['token']
  session['fb_error'] = nil
render :text => request.env['omniauth.auth'].to_yaml  
end

我一直在尝试解决这个问题:

Rails.application.config.middleware.use OmniAuth::Builder do  
  provider :facebook, 'MY_APPID', 'SECRET', {:scope => 'publish_stream,email', :client_options => {:ssl => {:verify => false}}}
end

Rails.application.config.middleware.use OmniAuth::Builder do  
  provider :facebook, 'MY_APPID', 'SECRET', {:scope => 'publish_stream,email', :client_options => {:ssl => {:ca_path => "#{Rails.root}/config/ca-bundle.crt"}}}
end

其中ca-bundle是:http://certifie.com/ca-bundle/ca-bundle.crt.txt

Rails.application.config.middleware.use OmniAuth::Builder do  
  provider :facebook, 'MY_APPID', 'SECRET', {:scope => 'publish_stream,email', :client_options => {:ssl => {:ca_path => "#{Rails.root}/config/cacert.pem"}}}
end

cacert.pem是:http://curl.haxx.se/ca/cacert.pem

我正在使用Windows 7.是否有人对此有解决方案或我做错了什么。 .pem.crt之间有什么区别?

1 个答案:

答案 0 :(得分:0)

Ruby无法找到任何根证书。

以下是调试目的的另一个选项:

require 'openssl'
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE

来源:https://stackoverflow.com/a/12032944/1047207(我对类似问题的回答)

您可能还需要查看此Blog