Skip to content

Instantly share code, notes, and snippets.

@marekyggdrasil
Created February 4, 2019 09:19
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save marekyggdrasil/95c9e855e9a081de3e80c99cdce16194 to your computer and use it in GitHub Desktop.
Save marekyggdrasil/95c9e855e9a081de3e80c99cdce16194 to your computer and use it in GitHub Desktop.
How to fix Ruby TLS support

OSX Sierra version 10.12.6

if you are getting error like

ERROR:  Could not find a valid gem '<some package name>' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - SSL_connect retur

test your TLS v1.2 support

$ ruby -ropenssl -e 'puts "TLS v1.2 support: #{OpenSSL::SSL::SSLContext::METHODS.include?(:TLSv1_2)}"'
TLS v1.2 support: false

notice you're getting false meaning not supported

$ brew install ruby
$ echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
$ export LDFLAGS="-L/usr/local/opt/ruby/lib"
$ export CPPFLAGS="-I/usr/local/opt/ruby/include"
$ export PKG_CONFIG_PATH="/usr/local/opt/ruby/lib/pkgconfig"
$ source ~/.bash_profile

test your TLS v1.2 support again

$ ruby -ropenssl -e 'puts "TLS v1.2 support: #{OpenSSL::SSL::SSLContext::METHODS.include?(:TLSv1_2)}"'
-e:1: warning: constant OpenSSL::SSL::SSLContext::METHODS is deprecated
TLS v1.2 support: true

notice you're getting true meaning it is supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment