craysiii / binance

API Wrapper for the Binance cryptocurrency exchange written in Ruby.
MIT License
97 stars 79 forks source link

SSLError #4

Open dave315 opened 6 years ago

dave315 commented 6 years ago

Hey! First of all thanks for making this Gem.

I am getting a Faraday::SSLError... have you encountered that before? Everything else in my app is working fine but as soon as I start to use this client I encounter Faraday::SSLError: SSL_connect returned=1 errno=0 state=error: certificate verify failed

Have you seen this before?

craysiii commented 6 years ago

Hey @dave315 - thanks for that!

Typically when I've encountered this error it has been because I was developing on Windows and didn't have the proper certificate file and environment variable set. Are you on Windows?

If that doesn't work please report back so I can further investigate the issue. SSL errors are no fun.

dave315 commented 6 years ago

@craysiii Yeah, I realized after I posted this that it is probably just something wrong with my machine. I'm using OSX and still haven't quite been able to figure out why this is happening yet. It must have something to do with my certs but I'm pretty bad at this stuff.

Not sure if it is worth investigating at all or if you could just close out the issue since I'm assuming this is an issue specific to me.

craysiii commented 6 years ago

Hey @dave315 - would love to help you on the issue.

Two questions:

andrewroth commented 6 years ago

I'm also getting this error. I use RVM and just updated to the latest, updated certs, and made sure that puts "SSL_CERT_FILE: %s" % OpenSSL::X509::DEFAULT_CERT_FILE gives a path that does exist with the certs. All looks right...

andrewroth commented 6 years ago

I'm running OS X El Capitan

craysiii commented 6 years ago

Hey @andrewroth - Thanks for the info.

This is definitely interesting and a bit puzzling. I was able to use the gem just fine on a clean install of High Sierra, with RVM installed through homebrew.

Does this happen on all endpoints, or only certain ones? I will investigate further tonight after work.

juancgarza commented 6 years ago

I've also encountered this error but have recently changed laptops. Have not tried it with the new one, still using OSx though.

craysiii commented 6 years ago

Hey @dave315 @andrewroth @juancgarza - Check out this github issue, which may have possible solutions for you. Seems like some people have had success setting the SSL_CERT_FILE environment variable and pointing it to an updated cacerts.pem like one would for the Windows fix. There are other solutions there as well, like upgrading to MRI 2.3+.

Hope this helps. Report back regardless please!

andrewroth commented 6 years ago

No go :(

2.3.1 :002 > ENV['SSL_CERT_FILE']
 => "/usr/local/etc/openssl@1.1/certs/cacert.pem" 
2.3.1 :003 > File.exists?(ENV['SSL_CERT_FILE'])
 => true 
2.3.1 :004 > $binance.ping
Faraday::SSLError: SSL_connect returned=1 errno=0 state=error: certificate verify failed
    from /Users/Andrew/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/net/http.rb:933:in `connect_nonblock'
    from /Users/Andrew/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/net/http.rb:933:in `connect'
    from /Users/Andrew/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/net/http.rb:863:in `do_start'
    from /Users/Andrew/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/net/http.rb:852:in `start'
    from /Users/Andrew/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/net/http.rb:1398:in `request'
    from /Users/Andrew/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/net/http.rb:1156:in `get'
    from /Users/Andrew/.rvm/gems/ruby-2.3.1/gems/faraday-0.12.2/lib/faraday/adapter/net_http.rb:78:in `perform_request'
    from /Users/Andrew/.rvm/gems/ruby-2.3.1/gems/faraday-0.12.2/lib/faraday/adapter/net_http.rb:38:in `block in call'
    from /Users/Andrew/.rvm/gems/ruby-2.3.1/gems/faraday-0.12.2/lib/faraday/adapter/net_http.rb:85:in `with_net_http_connection'
    from /Users/Andrew/.rvm/gems/ruby-2.3.1/gems/faraday-0.12.2/lib/faraday/adapter/net_http.rb:33:in `call'
    from /Users/Andrew/.rvm/gems/ruby-2.3.1/gems/faraday_middleware-0.12.2/lib/faraday_middleware/response_middleware.rb:31:in `call'
    from /Users/Andrew/.rvm/gems/ruby-2.3.1/gems/faraday_middleware-0.12.2/lib/faraday_middleware/request/encode_json.rb:24:in `call'
    from /Users/Andrew/.rvm/gems/ruby-2.3.1/gems/faraday-0.12.2/lib/faraday/rack_builder.rb:141:in `build_response'
    from /Users/Andrew/.rvm/gems/ruby-2.3.1/gems/faraday-0.12.2/lib/faraday/connection.rb:386:in `run_request'
    from /Users/Andrew/.rvm/gems/ruby-2.3.1/gems/faraday-0.12.2/lib/faraday/connection.rb:149:in `get'
    from /Users/Andrew/.rvm/gems/ruby-2.3.1/gems/binance-0.4.0/lib/binance/client/rest.rb:61:in `request'
... 3 levels...
    from /Users/Andrew/.rvm/gems/ruby-2.3.1@global/gems/railties-4.2.8/lib/rails/commands/console.rb:9:in `start'
    from /Users/Andrew/.rvm/gems/ruby-2.3.1@global/gems/railties-4.2.8/lib/rails/commands/commands_tasks.rb:68:in `console'
    from /Users/Andrew/.rvm/gems/ruby-2.3.1@global/gems/railties-4.2.8/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /Users/Andrew/.rvm/gems/ruby-2.3.1@global/gems/railties-4.2.8/lib/rails/commands.rb:17:in `<top (required)>'
    from /Users/Andrew/.rvm/gems/ruby-2.3.1@global/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `require'
    from /Users/Andrew/.rvm/gems/ruby-2.3.1@global/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `block in require'
    from /Users/Andrew/.rvm/gems/ruby-2.3.1@global/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:240:in `load_dependency'
    from /Users/Andrew/.rvm/gems/ruby-2.3.1@global/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `require'
    from /Users/Andrew/Development/arbitrator/bin/rails:9:in `<top (required)>'
    from /Users/Andrew/.rvm/gems/ruby-2.3.1@global/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:268:in `load'
    from /Users/Andrew/.rvm/gems/ruby-2.3.1@global/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:268:in `block in load'
    from /Users/Andrew/.rvm/gems/ruby-2.3.1@global/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:240:in `load_dependency'
    from /Users/Andrew/.rvm/gems/ruby-2.3.1@global/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:268:in `load'
    from /Users/Andrew/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/Andrew/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from -e:1:in `<main>'
andrewroth commented 6 years ago

another crypto library is having the same issue for people: https://github.com/ccxt/ccxt/issues/452

craysiii commented 6 years ago

That is really weird to say the least..

It would be easy to blame it on Binance, but I don't know if they really are the root cause, as I can ping and any other method just fine. How did you update your cacert.pem? What source did it come from?

andrewroth commented 6 years ago

I got it from the link in the stackoverflow for the windows fix. curl.haxx.se.. But I just noticed it's an empty file, so let me re-download that and try again

andrewroth commented 6 years ago

Yes, it works now! Thanks!

craysiii commented 6 years ago

Awesome! Happy coding :)