2013-06-12 2 views
6

Sto cercando di usare la gemma ruby ​​'twitter' ma per ragioni sconosciute non riesco a farla funzionare.Ruby Gem Twitter - Verifica certificato non riuscita (Twitter :: Errore :: Errore Client)

ecco il codice .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" 

e ottengo il seguente errore:

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>' 

Sono un novizio rubino e non posso dare un senso dell'errore cliente ... forse Mi manca qualcosa. Ho anche confermato che le mie credenziali Oauth funzionano in python.

Grazie in anticipo e attendo con impazienza il vostro aiuto.

risposta

9

Sono stato in grado di risolvere la mia stessa domanda. Per coloro che hanno lo stesso problema provare a utilizzare il seguente:

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

Si disattiva la sicurezza SSL, ma consente di elaborare con la risoluzione dei problemi. Il problema sottostante è un SSL obsoleto.

+1

Questo fa scomparire l'errore, ma non dovresti farlo davvero http://jamesgolick.com/2011/2/15/verify-none..html – jordelver

1

Sono molto nuovo anche a Ruby ma stai usando un Mac? Potrebbe essere dovuto a file di certificati SSL obsoleti. Ecco un link alle istruzioni che hanno risolto il problema per me. http://railsapps.github.io/openssl-certificate-verify-failed.html

+0

Io uso Windows 7. Non ho avuto fortuna con il collegamento e ho confermato che le mie variabili di percorso sono impostate. Ho anche disinstallato Ruby 2.0 e installato Ruby 1.93 e ho riscontrato lo stesso problema. Ho tweetstream attivo e funzionante. AIUTO! – tjrburgess