ruby-on-rails - ruby 控制台上的奇怪 ssl 错误

标签 ruby-on-rails ruby ssl rubygems

刚开始使用 Ruby,我无法克服下面发布的错误。这是我的代码:

require 'HTTParty'
require 'Nokogiri'
require 'JSON'
require 'Pry'
require 'csv'

page = HTTParty.get('https://newyork.craigslist.org/search/pet?s=0')

Pry.start(binding)

控制台错误:

C:/Ruby23/lib/ruby/2.3.0/net/http.rb:933:in connect_nonblock': SSL_connect returned=1 errno=0 state=error: certificate verify failed (OpenSSL::SSL::SSLError) from C:/Ruby23/lib/ruby/2.3.0/net/http.rb:933:inconnect' from C:/Ruby23/lib/ruby/2.3.0/net/http.rb:863:in do_start' from C:/Ruby23/lib/ruby/2.3.0/net/http.rb:852:instart' from C:/Ruby23/lib/ruby/2.3.0/net/http.rb:1398:in request' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/httparty-0.14.0/lib/httparty/request.rb:118:in perform' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/httparty-0.14.0/lib/HTTParty.rb:560:in perform_request' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/httparty-0.14.0/lib/HTTParty.rb:486:in get' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/httparty-0.14.0/lib/HTTParty.rb:598:in get' from web_scraper.rb:7:in'

我一直在线并替换了 GlobalSignRootCA.pem 并尝试重新运行但没有成功。还尝试卸载并重新安装 ruby 和 gem 。

最佳答案

这可能是因为请求试图验证您发送/接收的 ssl key 。

您可以通过添加来避免错误

verify: false

接听您的电话。

更多详情 here .

关于ruby-on-rails - ruby 控制台上的奇怪 ssl 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43881481/

相关文章:

ruby - Sinatra 找不到 View 目录

amazon-web-services - 如何在我的 AWS Elastic Beanstalk 环境中为解析服务器示例启用 HTTPS?

ruby - 如何同时使用 scala 和 rails 中的 memcached(Amazon elasticache)?

java - 配置 apache james 2.3.2 以支持 ssl : NoSuchAlgorithmException 时出错

Mysql Workbench 连接 ssl 未启用

ruby-on-rails - 将 "news_path"用于 :news resource doesn't work with `No route matches {:action=>"show", :controller= >"admin/news"} 缺少必需的键:[:id]'

ruby-on-rails - 无法安装 Ruby 1.9.3

ruby-on-rails - 使用 Minitest 测试自定义验证器

mysql - 'DELIMITER $$' 附近的错误

ruby-on-rails - 使用 rspec 和 rails 测试嵌套模块