在Windows 7上打开Ruby的SSL错误 [英] Open SSL Errors for Ruby on Windows 7

查看:97
本文介绍了在Windows 7上打开Ruby的SSL错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows 7正常操作系统上运行。

Ruby,SSL和Windows并不相互喜欢,所以像这样简单的命令对我来说不起作用,这让我非常头疼。我尝试过获得RVM,更新我的环境变量,几乎所有的东西。

我不知道解决方案是什么。有没有解决方案来安装Ruby 1.9.3的OpenSSL gem?

  require'mechanize'
agent =机械化.new
page = agent.get('https://any-ssl-site-here.com')
放置页面
https url时,基本上失败了,因为OpenSSL不知道在哪里寻找 ca_file



修复非常简单,获得一个CA Cert Bundle(我最喜欢的是 cURL的CA Bundle )并指定任何库'

mechanize 的情况下,他们使用 #ca_file instance方法



换句话说,将您的代码更改为:

  require'mechanize'
agent = Mechanize.new
agent.ca_file =path / to / ca_bundle.crt

page = agent.get('https://any-ssl-site-here.com')
puts page

另外,请查看 Luis Lavena对类似问题的特别回答

I'm running on Windows 7 normal OS.

Ruby, SSL, and Windows don't like each other, so simple commands like these don't work for me and it's giving me a real headache. I've tried getting RVM, updating my environmental variables, practically everything.

I don't know what the solution is. Is there a solution to install the OpenSSL gem for Ruby 1.9.3?

require 'mechanize'
agent = Mechanize.new
page = agent.get('https://any-ssl-site-here.com')
puts page

解决方案

So whenever you try to use libraries to access https urls on Windows they basically fail because OpenSSL doesn't know where to look for the ca_file.

The fix is pretty straight forward, get a CA Cert Bundle (my favorite is cURL's CA Bundle) and point whatever library you're going to use to it.

In the case of mechanize they do it using the #ca_file instance method.

In other words, change your code to:

require 'mechanize'
agent = Mechanize.new
agent.ca_file = "path/to/ca_bundle.crt"

page = agent.get('https://any-ssl-site-here.com')
puts page

Also, check out Luis Lavena's execellent answer to a similar question.

这篇关于在Windows 7上打开Ruby的SSL错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆