【问题标题】:SSL_connect SYSCALL returned=5 errno=0 state=SSLv2/v3 read server hello A - Faraday::Error::ConnectionFailedSSL_connect SYSCALL 返回=5 errno=0 state=SSLv2/v3 读取服务器 hello A - Faraday::Error::ConnectionFailed
【发布时间】:2014-04-22 15:22:30
【问题描述】:

我在这里看到了很多答案,但没有一个有效。

我正在使用omniauth-oauth2 gem 与第三方客户集成。

我正在使用here 描述的设置阶段,但我总是收到此错误:

Authentication failure! failed_to_connect: Faraday::Error::ConnectionFailed, SSL_connect SYSCALL returned=5 errno=0 state=SSLv2/v3 read server hello A

Faraday::Error::ConnectionFailed (SSL_connect SYSCALL returned=5 errno=0 state=SSLv2/v3     read server hello A):
.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:918:in `connect'
.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:918:in `block in connect'

我在config/initializers 的初始化程序是:

Rails.application.config.middleware.use OmniAuth::Builder do
  client_id = 'my_client_id'
  client_secret = 'secret'

  ca_file = Rails.root.join('config', 'cacert.pem').to_s

  ssl_options = {}
  ssl_options[:ca_path] = '/usr/local/etc/openssl'
  ssl_options[:ca_file] = ca_file

  provider :my_partner_provider, client_id, client_secret,  :client_options => {:ssl => ssl_options},
    setup: ->(env){
    req = Rack::Request.new(env)
    site = "https://#{req.params.fetch('shop')}"
    env['omniauth.strategy'].options[:client_options][:site]  = site
  }
end

我尝试过使用和不使用 ssl 选项。

作为补充,这是我的堆栈:https://gist.github.com/cleytonmessias/11274209

我在终端输入了openssl s_client -showcerts -connect partnerurl.com:443 <<<OK,它返回了这个:https://gist.github.com/cleytonmessias/11288646

有人知道这个问题的解决方法吗?

【问题讨论】:

  • 你找到解决办法了吗?
  • 我会说这是一个错误,但它可能不是来自 Net::HTTP。我在连接到 Sharepoint 服务时遇到了这个问题:wget 也无法连接,而 curl 完全没有问题。
  • 但是你解决了吗?我仍然没有找到任何东西。
  • 您使用的是什么 OpenSSL 版本?是系统一还是 RVM 自带的?
  • 明确设置ssl_version 有帮助吗? stackoverflow.com/a/9262269

标签: ruby-on-rails ruby omniauth


【解决方案1】:

感谢@mislav 提示更改SSL version

我必须更改此设置,因为我的合作伙伴使用 asp.net 构建其应用程序并使用此版本的 SSL。更多信息https://mislav.net/2013/07/ruby-openssl/

所以最终代码如下:

Rails.application.config.middleware.use OmniAuth::Builder do
  client_id = 'my_client_id'
  client_secret = 'secret'

  ssl_options = {}
  ssl_options[:version] = :TLSv1

  ssl = {}
  ssl[:ssl] =  ssl_options

  provider :partner, client_id, client_secret,
    client_options: { connection_opts: ssl} ,
    setup: ->(env){
    req = Rack::Request.new(env)
    token_url = "https://#{req.params.fetch('shop')}"
    env['omniauth.strategy'].options[:client_options][:token_url] = token_url
  }
end

【讨论】:

    猜你喜欢
    • 2011-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-25
    • 2014-11-06
    • 1970-01-01
    • 2017-06-03
    相关资源
    最近更新 更多