user419017
user419017

Reputation:

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.

Upvotes: 4

Views: 1865

Answers (2)

salah-1
salah-1

Reputation: 1399

For the sake of those having the same issues. I found my problem was because i had ssl: true in config/ldap.yml (if you have that make sure your ldap server is ssl). If that helps you select this as the answer for those who come next.

Upvotes: 1

Dmitriy Budnik
Dmitriy Budnik

Reputation: 1576

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

rvm reinstall 1.9.3

Upvotes: 2

Related Questions