I get SSL verify errors when running get calls against an SSL site from the rails console (or in the rails environment in general).
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=error: certificate verify failed
I've traced the entire rails application initialization process from start to finish, going from config.ru
all the way through, requiring environment files, etc.
The SSL error only starts happening after I run Rails.application.initialize!
in config/environment.rb
I purged all ruby gems from the system and only have the ones installed from the Gemfile
so it's impossible to have a different gem version required before/after the initialization process.
I know the short-term fix would be to set my HTTPS calls to not verify the cert it is getting but that is not possible due to security concerns in the production environment.
The problem seems to relate to SNI (Server Name Indication) given that when I run
openssl s_client -connect sub.domain.com:443 -showcerts -servername sub.domain.com
I get the proper CERT, but when I run
openssl s_client -connect sub.domain.com:443 -showcerts
I get a cert for sub2.domain.com
which is why the verify fails. How is this something that is changed by the Rails init process and if so, is there an option to tell rails to use SNI ?
- Rails v4.2.5.2
- ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux]
- OS: Fedora 25
- ca-certificates-2017.2.11-1.1.fc25_2017.2.14-1.0.fc25.noarch.drpm: done