gem install and ssl errors

fabian@heartofgold $ gem install somecoolgem
ERROR:  Could not find a valid gem 'somecoolgem' (>= 0), here is why:
          Unable to download data from -
          SSL_connect returned=1 errno=0 state=SSLv3 read server
          certificate B: certificate verify failed

Sounds common? There is a really easy solution in 3 steps:

  1. $ brew install curl-ca-bundle (if you don’t have Homebrew installed, then there is another surprising step..)
  2. $ export SSL_CERT_FILE=/usr/local/opt/curl-ca-bundle/share/ca-bundle.crt
  3. put the last one somewhere inside your .zshrc/.bashrc