とりあえず、以下を最初にやってからMechanize.newすると大丈夫っぽい*1
require 'openssl' OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
エラーになったやつ。
sora_h のniconico モジュールを使ったらエラーだった
?> require 'niconico' #=> true >> a=Niconico.new 'takuya***@gmail.com' , ‘****' #=> #<Niconico: takuy****@gmail.com (not logined) ?> >> a.login OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed from /Users/takuya/.rvm/gems/ruby-1.9.3-rc1/gems/net-http-persistent-2.3.3/lib/net/http/persistent/ssl_reuse.rb:70:in `connect' from /Users/takuya/.rvm/gems/ruby-1.9.3-rc1/gems/net-http-persistent-2.3.3/lib/net/http/persistent/ssl_reuse.rb:70:in `block in connect' from /Users/takuya/.rvm/rubies/ruby-1.9.3-rc1/lib/ruby/1.9.1/timeout.rb:54:in `timeout' from /Users/takuya/.rvm/rubies/ruby-1.9.3-rc1/lib/ruby/1.9.1/timeout.rb:99:in `timeout' from /Users/takuya/.rvm/gems/ruby-1.9.3-rc1/gems/net-http-persistent-2.3.3/lib/net/http/persistent/ssl_reuse.rb:70:in `connect' from /Users/takuya/.rvm/rubies/ruby-1.9.3-rc1/lib/ruby/1.9.1/net/http.rb:755:in `do_start' from /Users/takuya/.rvm/rubies/ruby-1.9.3-rc1/lib/ruby/1.9.1/net/http.rb:750:in `start' from /Users/takuya/.rvm/gems/ruby-1.9.3-rc1/gems/net-http-persistent-2.3.3/lib/net/http/persistent.rb:405:in `connection_for' from /Users/takuya/.rvm/gems/ruby-1.9.3-rc1/gems/net-http-persistent-2.3.3/lib/net/http/persistent.rb:616:in `request' from /Users/takuya/.rvm/gems/ruby-1.9.3-rc1/gems/mechanize-2.1/lib/mechanize/http/agent.rb:264:in `fetch' from /Users/takuya/.rvm/gems/ruby-1.9.3-rc1/gems/mechanize-2.1/lib/mechanize.rb:1036:in `post_form' from /Users/takuya/.rvm/gems/ruby-1.9.3-rc1/gems/mechanize-2.1/lib/mechanize.rb:380:in `post' from /Users/takuya/.rvm/gems/ruby-1.9.3-rc1/gems/niconico-1.1.3/lib/niconico.rb:30:in `login' from (irb):6 from /Users/takuya/.rvm/gems/ruby-1.9.3-rc1/gems/irb_rocket-0.2.0/lib/irb_rocket.rb:65:in `block in signal_status' from /Users/takuya/.rvm/gems/ruby-1.9.3-rc1/gems/irb_rocket-0.2.0/lib/irb_rocket.rb:26:in `call' from /Users/takuya/.rvm/gems/ruby-1.9.3-rc1/gems/irb_rocket-0.2.0/lib/irb_rocket.rb:26:in `capture' from /Users/takuya/.rvm/gems/ruby-1.9.3-rc1/gems/irb_rocket-0.2.0/lib/irb_rocket.rb:64:in `signal_status' from /Users/takuya/.rvm/rubies/ruby-1.9.3-rc1/bin/irb:16:in `<main>'>> ?>
MechanizeはSSL関係で、証明書関連でエラーになる。ってことらしい。
対処法
・証明書を入れる
・証明書エラーは無視する。
自分で使うなら後者
require 'openssl' OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE require 'mechanize'
これで、とりあえず、しばらく使えるようになるみたいですね。
*1:あくまでとりあえずですからね。