The following error appeared upon upgrading JRuby:
OpenSSL::X509::StoreError: setting default path failed: Invalid keystore format
wget http://curl.haxx.se/ca/cacert.pem
sudo keytool -importcert -file cacert.pem -keystore /Users/youruser/.keystore
export SSL_CERT_FILE=/Users/youruser/.keystore
jruby -S gem install whatever
I have been plagued by this issue and used this solution for a long while (thank you!) but its has recently stopped working for me. I believe the cause was that the JRuby installer through RVM was installing an older version of jruby-openssl or simply relying on an out-of-date version of OpenSSL.
The solution for me was to brew uninstall and reinstall my local version of OpenSSL:
RVM implode (not sure if this is necessary but I wanted a fresh start)
Follow the steps here to uninstall/reinstall OpenSSL: http://apple.stackexchange.com/questions/126830/how-to-upgrade-openssl-in-os-x
Reinstall RVM/JRuby using: \curl -sSL https://get.rvm.io | bash -s stable --ruby=jruby
And I was good to go!