【问题标题】:Ruby Gem Twitter - certificate verify failed (Twitter::Error::ClientError)Ruby Gem Twitter - 证书验证失败(Twitter::Error::ClientError)
【发布时间】:2013-06-09 05:50:47
【问题描述】:

我正在尝试使用 ruby​​ gem 'twitter',但由于未知原因,我无法使用它。

这是.rb代码:

require 'twitter'

puts "Greetings, World!"
puts "Checkpoint 1"
Twitter.configure do |config|
  config.consumer_key = "xxxxxxx" #removed for posting
  config.consumer_secret = "xxxxxxx" #removed for posting
  config.oauth_token = "xxxxxxx" #removed for posting
  config.oauth_token_secret = "xxxxxxx" #removed for posting
end
Twitter.verify_credentials
puts "Checkpoint 2"

我收到以下错误:

Greetings, World!
Checkpoint 1
C:/Ruby200-x64/lib/ruby/2.0.0/net/http.rb:918:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (Twitter::Error::ClientError)
from C:/Ruby200-x64/lib/ruby/2.0.0/net/http.rb:918:in `block in connect'
from C:/Ruby200-x64/lib/ruby/2.0.0/timeout.rb:66:in `timeout'
from C:/Ruby200-x64/lib/ruby/2.0.0/net/http.rb:918:in `connect'
from C:/Ruby200-x64/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
from C:/Ruby200-x64/lib/ruby/2.0.0/net/http.rb:851:in `start'
from C:/Ruby200-x64/lib/ruby/2.0.0/net/http.rb:1367:in `request'
from C:/Ruby200-x64/lib/ruby/2.0.0/net/http.rb:1126:in `get'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/faraday-0.8.7/lib/faraday/adapter/net_http.rb:73:in `perform_request'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/faraday-0.8.7/lib/faraday/adapter/net_http.rb:38:in `call'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/faraday-0.8.7/lib/faraday/response.rb:8:in `call'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/faraday-0.8.7/lib/faraday/response.rb:8:in `call'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/faraday-0.8.7/lib/faraday/response.rb:8:in `call'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/faraday-0.8.7/lib/faraday/request/url_encoded.rb:14:in `call'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/faraday-0.8.7/lib/faraday/request/multipart.rb:13:in `call'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/twitter-4.8.0/lib/twitter/request/multipart_with_file.rb:14:in `call'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/faraday-0.8.7/lib/faraday/connection.rb:247:in `run_request'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/faraday-0.8.7/lib/faraday/connection.rb:100:in `get'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/twitter-4.8.0/lib/twitter/client.rb:108:in `request'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/twitter-4.8.0/lib/twitter/client.rb:66:in `get'        
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/twitter-4.8.0/lib/twitter/api/utils.rb:82:in `object_from_response'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/twitter-4.8.0/lib/twitter/api/users.rb:50:in `verify_credentials'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/twitter-4.8.0/lib/twitter.rb:60:in `method_missing'
from C:/Ruby200-x64/AppCode/twitter_connect.rb:13:in `<main>'

我是一个红宝石新手,我无法理解客户端错误......也许我错过了一些东西。我还确认我的 Oauth 凭据在 python 中工作。

提前致谢,期待您的帮助。

【问题讨论】:

    标签: ruby twitter oauth gem


    【解决方案1】:

    我能够解决我自己的问题。对于那些有同样问题的人,请尝试使用以下方法:

    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
    

    它会禁用 SSL 安全性,但它允许您处理故障排除。根本问题是 SSL 过时。

    【讨论】:

    【解决方案2】:

    我对 ruby​​ 也很陌生,但您使用的是 Mac 吗?可能是因为 SSL 证书文件过时。这是为我解决问题的说明的链接。 http://railsapps.github.io/openssl-certificate-verify-failed.html

    【讨论】:

    • 我使用的是 Windows 7。链接没有任何运气,我已经确认我的路径变量已设置。我还卸载了 ruby​​ 2.0 并安装了 ruby​​ 1.93,我遇到了同样的问题。我已经启动并运行了推文流。帮助!
    猜你喜欢
    • 2016-11-26
    • 2013-02-23
    • 2014-05-01
    • 1970-01-01
    • 2015-10-11
    • 2012-04-12
    • 2015-06-05
    • 2015-02-18
    • 1970-01-01
    相关资源
    最近更新 更多