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.
来源:https://stackoverflow.com/questions/31867930/open-ssl-errors-for-ruby-on-windows-7