为什么我只在 Windows 上收到 OpenSSL::SSL::SSLError ?

发布于 2024-09-01 02:50:53 字数 1384 浏览 6 评论 0原文

我正在从 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 patchlevel 287。这是怎么回事?我们知道我们可以关闭 SSL 验证并且它有效(或者至少看起来有效),但这似乎是一个糟糕的解决方案。

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

更新:看起来 Mechanize 的问题可能是 Windows 7 特有的,与我之前的想法不同。不过,就在几周前,它还发挥了作用。

更新 2: Windows(XP 和 7)上仍然会发生这种情况,但 Linux 上不会。不过,在我需要制作的重要脚本中,这不再是一个问题——仍然不确定为什么。

I'm downloading files from a HTTPS website. I've narrowed the problem down to this:

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

This code works just fine on Mac OS X or Linux, but it just started failing on Windows. I've tested on a few Win XP installations and one Win 7 installation -- they all fail. They're all running Ruby 1.8.6 patchlevel 287. What's going on here? We know we can turn off SSL verification and it works (or at least seems to), but that seems like a poor solution.

I'm interfacing with the website in question using Mechanize, so I'd like to be able to continue to use that.

Update: It looks like the problem with Mechanize might be specific to Windows 7, unlike I previously thought. It worked just a couple of weeks ago, though.

Update 2: This is still happening on Windows (XP and 7), but not on Linux. It's no longer a problem in the important script I needed to make work, though -- still not sure why.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

北方的巷 2024-09-08 02:50:53

出现这种情况是因为 ruby​​ 没有附带证书吗? http://betterlogic.com/roger/2011/08/github- jruby-ssl-woe/

appears it happens because ruby doesn't ship with certificates? http://betterlogic.com/roger/2011/08/github-jruby-ssl-woe/

别理我 2024-09-08 02:50:53

区别可能在于 32 位和 64 位架构吗?

Could the difference be 32-bit vs 64-bit architecture?

蓝戈者 2024-09-08 02:50:53

我自己也在寻求同样的解决方案。我使用 cURL 和设置 CA 捆绑包的信息在命令行上解决了此问题。我仍在寻找 Ruby 修复程序。

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

I'm seeking the same solution myself. I resolved this issue on the command line using cURL and the information to set-up a CA-bundle. I'm still looking for a Ruby fix.

This is a common issue across on Linux, Windows, Windows, Mac, Ruby 1.8, Ruby 1.9 and JRuby from my testing/experiments.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文