gpt4 book ai didi

ruby-on-rails - SSL_connect SYSCALL returned=5 errno=0 state=SSLv2/v3 读取服务器 hello A - Faraday::Error::ConnectionFailed

转载 作者:数据小太阳 更新时间:2023-10-29 06:50:32 26 4
gpt4 key购买 nike

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

我正在使用 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

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

最佳答案

感谢@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

关于ruby-on-rails - SSL_connect SYSCALL returned=5 errno=0 state=SSLv2/v3 读取服务器 hello A - Faraday::Error::ConnectionFailed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23223691/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com