http://railsapps.github.io/openssl-certificate-verify-failed.html
Finally solve the problem:
brew install openssl
brew link openssl
cd /usr/local/etc/openssl/certs/
sudo curl -O https://curl.haxx.se/ca/cacert.pem
sudo mv cacert.pem cert.pem
cd -
echo "export SSL_CERT_FILE=/usr/local/etc/openssl/certs/cert.pem" >> ~/.bash_profile
source ~/.bash_profile
unset SSL_CERT_FILE