SSL certificate error with elasticsearch gem on ruby 2.2.2

I don't know exactly why but with Ruby 2.2.2p95 on OSX I get the following error when I try to use the elasticsearch gem:

Faraday::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

To fix it, just try to avoid using rubys build in Net::HTTP lib and switch to another one (for example typheous). Just add it to your Gemfile, let Bundler run and the elasticsearch gem will use it by itself:

gem 'typhoeus', require: 'typhoeus/adapters/faraday'

Set your paths right for rbenv and all the other cool stuff you're using

Rbenv is awesome. I find it the most simple solution to handle different Ruby versions. But if you use it with tons of other stuff like brew and heroku you have to take care in what order you set your paths to use everytime the right bins for loading your applications. Here is what I use in my .bash_profile:

export PATH="$HOME/.rbenv/bin:/usr/local/bin:/usr/local/sbin:/usr/local/heroku/bin:$PATH"
eval "$(rbenv init -)"
export PATH="./.bundle/bin:$PATH"

First add heroku, then add everything related to brew and then add everything related to rbenv. After this, load rbenv and your currently selected Ruby version. If you find gemsets useless like I do add the last line of the example also. This will load all the binstubs in the current directory that you can create with the --binstubs option for bundler. To make it even more convenient add this also to your .bash_profile:

alias bi='bundle --binstubs .bundle/bin'

Now you can bundle with binstubs by just typing "bi" and all gems and bins will load in the following order:

  1. project specific gems in the current folder
  2. ruby specific gems from with rbenv currently selected ruby version
  3. gems/bins installed with brew
  4. gems/bin installed in the system

instagram

instagram

instagram