Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSL Verification failed on Windows #392

Closed
briceo opened this issue Jul 18, 2014 · 7 comments
Closed

SSL Verification failed on Windows #392

briceo opened this issue Jul 18, 2014 · 7 comments

Comments

@briceo
Copy link

briceo commented Jul 18, 2014

It appears that when trying to use Faraday on Windows to communicate with a site that is SSL, a certificate verify failed error occurs:

irb(main):001:0> require 'faraday'
=> true
irb(main):002:0> Faraday.get('https://google.com')
Faraday::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
        from C:/Ruby200/lib/ruby/2.0.0/net/http.rb:918:in `connect'
        from C:/Ruby200/lib/ruby/2.0.0/net/http.rb:918:in `block in connect'
        from C:/Ruby200/lib/ruby/2.0.0/timeout.rb:52:in `timeout'
        from C:/Ruby200/lib/ruby/2.0.0/net/http.rb:918:in `connect'
        from C:/Ruby200/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
        from C:/Ruby200/lib/ruby/2.0.0/net/http.rb:851:in `start'
        from C:/Ruby200/lib/ruby/2.0.0/net/http.rb:1367:in `request'
        from C:/Ruby200/lib/ruby/2.0.0/net/http.rb:1126:in `get'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/faraday-0.9.0/lib/faraday/adapter/net_http.rb:78:in `perform_request'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/faraday-0.9.0/lib/faraday/adapter/net_http.rb:39:in `call'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/faraday-0.9.0/lib/faraday/request/url_encoded.rb:15:in `call'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/faraday-0.9.0/lib/faraday/rack_builder.rb:139:in `build_response'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/faraday-0.9.0/lib/faraday/connection.rb:377:in `run_request'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/faraday-0.9.0/lib/faraday/connection.rb:140:in `get'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/faraday-0.9.0/lib/faraday.rb:99:in `method_missing'
        from (irb):2
        from C:/Ruby200/bin/irb:12:in `<main>'

This same example works correctly from a linux system, and retrieves the expected webpage with no errors.

@briceo
Copy link
Author

briceo commented Jul 18, 2014

I was able to work around this issue by setting the environment variable SSL_CERT_FILE to the full path of my cacert.pem file (which I obtained from here: http://curl.haxx.se/docs/caextract.html).

@lamont-granquist
Copy link

that is the correct solution to the problem, faraday has nothing to do with it, see oneclick/rubyinstaller#226

@timcy
Copy link

timcy commented Nov 20, 2014

i have same issue with ubuntu system with facebook authentication.

@Kagetsuki
Copy link

@timcy I suspect your issue is unrelated.

Unless there is some proposal for a built-in workaround I think this issue should be closed. It's still present but I can confirm it has nothing to do with faraday; I'm confirming it's a windows/ruby-installer issue.

@mislav
Copy link
Contributor

mislav commented Dec 8, 2015

@briceo Thanks for sharing the workaround!

I'm afraid there's not much we can do from Faraday. Developers who need to connect to sites over HTTPS are responsible for ensuring that root certificates are already in place.

@cqcn1991
Copy link

@briceo Hi, can you give a more specific solution to this problem? I'm on windows and also have this problem. But I already have SSL_CERT_FILE to cacert.pem full pacht (i.e., D:\RailsInstaller\cacert.pem)

@Kagetsuki
Copy link

The problem is SSL_CERT_FILE (or maybe it was some other environment variable) needs to be an aboslute path for some reason, and that path is hard coded into something that was generated by whoever compiled that component of the rails installer.

Grab the root certs from somewhere else, save them locally, then point to them. EG:
https://github.com/emojidex/emojidex/blob/master/lib/emojidex/service/transactor.rb#L110

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants