2010-05-07 63 views
0

我正在從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上。儘管我需要做重要的腳本,但這不再是問題 - 仍然不知道爲什麼。

回答

0

區別是32位還是64位體系結構?

+0

這是可能的。我再也不能訪問有問題的機器了,所以我無法測試這個假設。 – 2011-01-13 01:34:21

+0

它是跨平臺和體系結構的SSL和Ruby OpenSSL特性(請參見上面的答案)。我認爲,民間不要單獨安全或加密。這會造成混亂,但也可能出現這樣的情況,即關鍵中間件模塊上的配置可能是_problematic_。 (只是一個_pov_) – will 2011-03-05 11:21:05

0

我正在尋求同樣的解決方案。我在命令行上使用cURL解決了此問題並提供了設置CA捆綁的信息。我仍然在尋找一個Ruby修補程序。

這是來自我的測試/實驗的Linux,Windows,Windows,Mac,Ruby 1.8,Ruby 1.9和JRuby中的一個常見問題。

相關問題