gpt4 book ai didi

ruby - 使用 Net::HTTP 发出 post 请求时 OpenSSL::SSL::SSLError

转载 作者:可可西里 更新时间:2023-11-01 17:08:56 24 4
gpt4 key购买 nike

我尝试了不同的方法(来自谷歌)来解决这个错误,但失败了。我无法解决这个问题。

我的代码是这样的:

require 'net/http'
require 'uri'
require 'json'

uri = URI.parse "https://dev.ramble.com/v1/user/login"
uri.user = "user1"
uri.password = "mypass"
connection = Net::HTTP::new uri.host, uri.port
connection.use_ssl = true
connection.ca_file = "/usr/local/etc/openssl/cert.pem"
connection.verify_mode=OpenSSL::SSL::VERIFY_PEER
session = connection.start

它引发了以下错误:

OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
from /Users/cmthakur/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/net/http.rb:920:in `connect'
from /Users/cmthakur/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/net/http.rb:920:in `block in connect'
from /Users/cmthakur/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/timeout.rb:76:in `timeout'
from /Users/cmthakur/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/net/http.rb:920:in `connect'
from /Users/cmthakur/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/net/http.rb:863:in `do_start'
from /Users/cmthakur/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/net/http.rb:858:in `start'

如果有人帮助我解决这个错误,我将非常感激。

最佳答案

关于ruby - 使用 Net::HTTP 发出 post 请求时 OpenSSL::SSL::SSLError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28189826/

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