This morning we started seeing gem
fail to build with this error:
Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: tlsv1 alert protocol version
I confirmed it was an openSSL version issue:
bash-3.2$ openssl s_client -connect rubygems.org:443
CONNECTED(00000003)
608:error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version:/BuildRoot/Library/Caches/com.apple.xbs/Sources/OpenSSL098/OpenSSL098-64.50.6/src/ssl/s23_clnt.c:593:
In lieu of a system upgrade, we ended up using DYLD
flags to point ruby at the homebrew-installed openssl version (which fixes it), but this is definitely a hack.
export HOMEBREW_OPENSSL_LIB=/usr/local/opt/openssl/lib
# Use the homebrew openssl 1.0
cp $HOMEBREW_OPENSSL_LIB/libcrypto.1.0.0.dylib $HOMEBREW_OPENSSL_LIB/libcrypto.0.9.8.dylib
cp $HOMEBREW_OPENSSL_LIB/libssl.1.0.0.dylib $HOMEBREW_OPENSSL_LIB/libssl.0.9.8.dylib
# Copy ruby to /tmp/ because we can't change DYLD flags on restricted bins
cp `which ruby` /tmp/ruby
# Run gem w/the homebrew lib
sudo DYLD_LIBRARY_PATH=/usr/local/opt/openssl/lib /tmp/ruby `which gem` install [...]