【发布时间】:2014-07-02 10:48:50
【问题描述】:
我正在尝试在 CentOS 6.2 中运行以下代码(取自 codeacademy):
require 'rubygems'
require 'oauth'
# Change the following values to those provided on dev.twitter.com
# The consumer key identifies the application making the request.
# The access token identifies the user making the request.
consumer_key = OAuth::Consumer.new(
"MY_KEY",
"MY_SECRET")
access_token = OAuth::Token.new(
"STRING1",
"STRING2")
# All requests will be sent to this server.
baseurl = "https://api.twitter.com"
# The verify credentials endpoint returns a 200 status if
# the request is signed correctly.
address = URI("#{baseurl}/1.1/account/verify_credentials.json")
# Set up Net::HTTP to use SSL, which is required by Twitter.
http = Net::HTTP.new address.host, address.port
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
# Build the request and authorize it with OAuth.
request = Net::HTTP::Get.new address.request_uri
request.oauth! http, consumer_key, access_token
# Issue the request and return the response.
http.start
response = http.request request
puts "The response status was #{response.code}"
并得到以下错误信息:
/usr/lib/ruby/1.8/net/http.rb:586:in `connect': SSL_connect 返回=1 errno=0 state=SSLv3 读取服务器证书B:证书验证 失败(OpenSSL::SSL::SSLError)
密钥已被省略(毕竟它们是秘密的),但我使用的是正确的。 安装了必要的 gem。
可能是什么问题?
【问题讨论】: