I recently upgraded to Mountain Lion and reinstalled Ruby 1.9.3 with RVM. Today I needed some SSL connections to interface with a payment gateway in a Rails application and this error showed up:
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
The OpenSSL library can't verify the Certificate Authority (CA) the certificate from the responding server is signed against and breaks. Certificates are verified using a chain of trust. The certficate should be verified by his parent, which, in his turn should be verified by his parent untill you reach a root certificate.
You'll need a CA bundle. The cURL website maintains a version of the Mozilla CA bundle in PEM format. Grab one of their certificates.
Once dowloaded you can tell Net::HTTP to use this certificate:
Or, my prefered way, you can use an environment variable and not have hard coded paths:
Or, install it in your RVM directory: Fix OpenSSL Error on Mountain Lion (and RVM).
This post is open source. Did you spot a mistake? Ideas for improvements? Contribute to this post via Github. Thank you!