gpt4 book ai didi

ruby-on-rails - Httpary: OpenSSL::SSL::SSLError

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

我一直在使用 httpparty 与我的 Rails 应用程序的 API 进行通信我遇到的问题是什么时候决定在不同的服务器上运行它。我们不断收到此错误:

SSL_connect returned=1 errno=0 state=unknown 状态:tlsv1 警报协议(protocol)版本

它在我当前的环境中运行良好,没有任何错误,所以我不确定我缺少什么才能让它在我的其他服务器上运行

我的代码:

    require 'httparty'
require 'pp'
require 'openssl'

def self.get_token

include HTTParty

base_uri = self.base_url
base_uri = base_uri+'oauth/'+'token'
response = HTTParty.post(base_uri,verify:false,
:body =>{
:grant_type=>'password',
:client_id=>'3',
:client_secret=> 'eGSjPBZV70IsJwnyjNn7EYI6vci0bGrFbJkJNVof',
:password=>'Passw0rd!',
:username=>'myemail@gmail.com'
},)
token = response.parsed_response['access_token']


return token
end `

最佳答案

您收到的是警报/警告,而不是错误。这是可能的,因为由于安全问题不推荐您使用的 TLS 版本。

根据 HTTParty documentation ,您可以使用以下代码更改 TLS 版本:

ssl_version :SSLv3

试试这个 v3 版本或 v2 版本,看看它是否删除了警告消息。

关于ruby-on-rails - Httpary: OpenSSL::SSL::SSLError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50617136/

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