使用HTTPS的SSL错误Twitter请求

时间:2013-07-26 04:47:44

标签: ruby https twitter

我的代码中定义了

消费者令牌哈希

access_token = OAuth::AccessToken.from_hash(consumer, token_hash)
url = URI.encode("https://api.twitter.com/1.1/statuses/update.json?status=awesome!")
response = access_token.request(:post, url)

它给了我们

OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
    from /usr/lib/ruby/1.8/net/http.rb:586:in `connect'
    from /usr/lib/ruby/1.8/net/http.rb:586:in `connect'
    from /usr/lib/ruby/1.8/net/http.rb:553:in `do_start'
    from /usr/lib/ruby/1.8/net/http.rb:542:in `start'
    from /usr/lib/ruby/1.8/net/http.rb:1035:in `__request__'
    from /usr/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient/net_http_ext.rb:51:in `request'
    from /usr/lib/ruby/gems/1.8/gems/oauth-0.4.7/lib/oauth/consumer.rb:161:in `request'
    from /usr/lib/ruby/gems/1.8/gems/oauth-0.4.7/lib/oauth/tokens/consumer_token.rb:25:in `request'
    from /usr/lib/ruby/gems/1.8/gems/oauth-0.4.7/lib/oauth/tokens/access_token.rb:12:in `request'

请帮帮我

2 个答案:

答案 0 :(得分:1)

使用最新的RVM(Ruby版本管理器)通过使用Ruby on Rail框架来修复第三方应用程序集成。

有关详情,请参阅此处的分步指南 - OpenSSL Errors and Rails Certificate Verify Failed

希望它有所帮助!

答案 1 :(得分:0)

我有同样的错误。我仍然无法解决根本问题,但尝试将其粘贴到您的.rb文件中。

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

它基本上会关闭验证步骤。