为什么我只在Windows上获得OpenSSL :: SSL :: SSLError?

时间:2010-05-07 21:11:48

标签: ruby ssl https

我正在从HTTPS网站下载文件。我把问题缩小到了这个范围:

>> 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补丁级别287.这里发生了什么?我们知道我们可以关闭SSL验证并且它可以工作(或者至少看起来如此),但这似乎是一个糟糕的解决方案。

我正在使用Mechanize与相关网站进行交互,所以我希望能够继续使用它。

更新:与我之前的想法不同,看起来Mechanize的问题可能与Windows 7有关。不过,它在几周前就开始工作了。

更新2:这仍然发生在Windows(XP和7)上,但不会发生在Linux上。然而,在我需要工作的重要脚本中不再是问题 - 仍然不确定原因。

3 个答案:

答案 0 :(得分:0)

差异可能是32位还是64位架构?

答案 1 :(得分:0)

我自己也在寻找相同的解决方案。我使用cURL在命令行上解决了这个问题以及设置CA-bundle的信息。我还在寻找Ruby修复程序。

这是我测试/实验中Linux,Windows,Windows,Mac,Ruby 1.8,Ruby 1.9和JRuby的常见问题。

答案 2 :(得分:0)

似乎是因为ruby没有附带证书? http://betterlogic.com/roger/2011/08/github-jruby-ssl-woe/