Open SSL Errors for Ruby on Windows 7

这一生的挚爱 提交于 2019-12-04 21:19:17
Azolo

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!