Search code examples
rubyopensslrvmruby-1.9.3rbenv

Can't make https connection with ruby


I've tried over 5 different versions of ruby, currently using 1.9.2-p194. I receive this error:

Connection reset by peer - SSL_connect (Errno::ECONNRESET)

I've recompiled, I tried rvm, rbenv, and even apt-get ruby...this works:

openssl ssl_client -connect google.com:443

Yet this doesn't:

require "net/https"
require "uri"

uri = URI.parse("https://google.com/")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

http.start do |agent|
  p agent.get(uri.path).read_body
end

Does anybody have any ideas how I can better debug this? I'm using Ubuntu 12.04. Locally, where this works, I'm using Ubuntu 10.10. However, openssl ssl_client work on both OS's and so I can only assume it is a ruby issue.

EDIT:

Got it to work using rbenv 1.9.2-p320, yet same ruby version didn't work under rvm. I'd appreciate any insight.


Solution

  • I suppose you have to re-install(re-compile) Ruby after installing OpenSSL with:

    rvm reinstall 1.9.3