0

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
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
  • Welcome to Stack Overflow. Your code snippet has little to nothing to do with your question. Why are you using Ruby 1.9.3? It's not actively supported. See " [Does RVM work on windows? Will it in the future?](https://rvm.io/support/faq#does-rvm-work-on-windows-will-it-in-the-future). Have you tried https://www.openssl.org/related/binaries.html? You've told us little except you've tried "practically everything" which tells us nothing. We need facts, what you've done, what were the errors. – the Tin Man Aug 07 '15 at 00:58
  • Well lots of stuff broke when i used ruby 2.2.1 and 2.2.0, so i was like screw it. And the error was: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed I've done basically everything with RVM such as Cygwin install and some other root installs that all lead to errors such as "this item is not in the repo" So I've done everything that I know of, but if you have a suggestions please list them? thanks – Sam Constante Aug 07 '15 at 01:40
  • I can't tell you the exact way to do it of the to of my head, but you need to get a copy of the OpenSSL Root Certs and point OpenSSL to them. I think environment variables. I'll get a better answer when I get a chance. – Azolo Aug 07 '15 at 16:17

1 Answers1

0

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.

Community
  • 1
  • 1
Azolo
  • 4,353
  • 1
  • 23
  • 31