gpt4 book ai didi

ruby - SYSCALL returned=5 errno=0 state=SSLv3 read server hello A with Ruby RESTful client

转载 作者:太空宇宙 更新时间:2023-11-03 16:22:40 24 4
gpt4 key购买 nike

我一直在为这个问题苦苦挣扎一段时间。我正在尝试使用 Rest-Client ruby​​ gem 来使用 SSL 证书访问 API 端点。我确定服务器仅响应 TLSv_1_2 和 TLSv_1_1,但我似乎无法使其正常工作。这是代码片段:

resource = RestClient::Resource.new(
endpoint,
:ssl_client_cert => OpenSSL::X509::Certificate.new(File.read(config["cert"])),
:ssl_client_key => OpenSSL::PKey::RSA.new(File.read(config["key"])),
:ssl_version => :TLSv1_2,
:verify_mode => OpenSSL::SSL::VERIFY_PEER
)

response = resource.delete(:params => {:name => 'test'})

p endpoint + " | " + response.code.to_s

这就是我得到的:

/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/http.rb:923:in `connect': SSL_connect SYSCALL returned=5 errno=0 state=SSLv3 read server hello A (OpenSSL::SSL::SSLError)
from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/http.rb:923:in `block in connect'
from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/timeout.rb:74:in `timeout'
from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/http.rb:923:in `connect'
from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/http.rb:863:in `do_start'
from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/http.rb:852:in `start'
from /usr/local/rvm/gems/ruby-2.2.1/gems/rest-client-1.8.0/lib/restclient/request.rb:413:in `transmit'
from /usr/local/rvm/gems/ruby-2.2.1/gems/rest-client-1.8.0/lib/restclient/request.rb:176:in `execute'
from /usr/local/rvm/gems/ruby-2.2.1/gems/rest-client-1.8.0/lib/restclient/request.rb:41:in `execute'
from /usr/local/rvm/gems/ruby-2.2.1/gems/rest-client-1.8.0/lib/restclient
from test.rb:47:in `<main>'

我一直在看this有一段时间了,但没什么帮助。

最佳答案

强烈建议使用顶级初始化程序:

conf/initializer/tls_settings.rb

OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:ssl_version] = 'TLSv1_2'

关于ruby - SYSCALL returned=5 errno=0 state=SSLv3 read server hello A with Ruby RESTful client,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31358003/

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