我正在從HTTPS網站下載文件。我已經縮小問題到這一點:爲什麼我只能在Windows上獲得OpenSSL :: SSL :: SSLError?
>> require 'open-uri'
>> open('https://www.gmail.com/') # just as an example
C:/Ruby/lib/ruby/1.8/net/http.rb:586:in `connect': certificate verify failed (OpenSSL::SSL::SSLError)
from C:/Ruby/lib/ruby/1.8/net/http.rb:586:in `connect'
from C:/Ruby/lib/ruby/1.8/net/http.rb:553:in `do_start'
from C:/Ruby/lib/ruby/1.8/net/http.rb:542:in `start'
from C:/Ruby/lib/ruby/1.8/open-uri.rb:242:in `open_http'
from C:/Ruby/lib/ruby/1.8/open-uri.rb:616:in `buffer_open'
from C:/Ruby/lib/ruby/1.8/open-uri.rb:164:in `open_loop'
from C:/Ruby/lib/ruby/1.8/open-uri.rb:162:in `catch'
from C:/Ruby/lib/ruby/1.8/open-uri.rb:162:in `open_loop'
from C:/Ruby/lib/ruby/1.8/open-uri.rb:132:in `open_uri'
from C:/Ruby/lib/ruby/1.8/open-uri.rb:518:in `open'
from C:/Ruby/lib/ruby/1.8/open-uri.rb:30:in `open'
from openuri_sandbox.rb:3
此代碼工作就好在Mac OS X或Linux,但它只是開始沒有在Windows上。我已經在幾個Win XP安裝和一個Win 7安裝上進行了測試 - 它們都失敗了。他們都運行Ruby 1.8.6 patchlevel 287.這裏發生了什麼?我們知道我們可以關閉SSL驗證,並且它可以工作(至少似乎是),但這似乎是一個糟糕的解決方案。
我與使用機械化問題的網站接口,所以我想能夠繼續使用它。
更新:它看起來像機械化的問題可能是特定於Windows 7,不像我以前認爲的。不過幾周之前它就起作用了。
更新2:這仍然發生在Windows(XP和7)上,但不是在Linux上。儘管我需要做重要的腳本,但這不再是問題 - 仍然不知道爲什麼。
我遇到了與Ruby處理證書有關的其他問題,這是我現在最好的猜測。 – 2012-11-26 21:16:41