Before attempting to solve this, I had no clue how certs or SSL worked, so please bear with my n00b-ness.
I'm currently using the Savon gem (v. 0.9.9) to try and connect to a SOAP-based web-service over HTTPS. However, I'm having a difficult time making successful calls.
As I understand the SSL/TSL protocol, the client sends the initial 'client hello' message to the server, to which the server responds with a 'server hello', which includes the server's digital certificate. The client will check that cert's chain against the local Cert Authority bundle to see if said cert can be trusted. That being said, here's what I've tried.
Update RVM CA certs: At first, I was getting the same error described in this SO thread, and I learned that Ruby checks the CA certs. I also found these instructions on updating the CA certs that RVM uses. So I ran the following in iTerm:
rvm osx-ssl-certs status all
and I got the following output:
Certificates for /Users/user-name/.rvm/usr/ssl/cert.pem: Up to date.
However, this still didn't allow me to successfully make SOAP calls over HTTPs.
Check if remote server's SSL cert is valid: I learned about the openssl CI tool from here, and so I figured perhaps the issue isn't me. Perhaps the issue is with the certificate itself. So I ran the following command in iTerm:
openssl s_client -connect [HOST]:[PORT] -showcerts
In addition to the certificate itself, I got the following in the output:
Verify return code: 18 (self signed certificate)
As I understand it, since this cert is self-signed, then unless it itself was a trusted CA, then of course it could never be verified. So the issue isn't with the certificate, the problem is with my local CA bundle.
Update local CA bundle: As I understand it, cert.pem is a list of trusted CA certs. I actually found two such files on my local machine:
/Users/user-name/.rvm/usr/ssl/cert.pem
and
/System/Library/OpenSSL/cert.pem
I wasn't sure which one I should update, so I ended up copying one of those files into my app's directory, copied & pasted the certificate into new local cert.pem, and tried again. Unfortunately I now get the following:
OpenSSL::SSL::SSLError: hostname does not match the server certificate
At this point, I'm not really sure what to do since as far as I can tell, the certificate should now be treated as a trusted certificate. Here's my code at the moment:
$SOAP_CORE = Savon::Client.new do |wsdl, http|
http.auth.ssl.ca_cert_file = path_to_local_cert.pm
http.auth.ssl.verify_mode = :peer
wsdl.document = path_to_remote_wsdl_over_https
end