Skip to content

Instantly share code, notes, and snippets.

@souzagab
Last active December 24, 2023 06:26
Show Gist options
  • Select an option

  • Save souzagab/0ae60e61939d51385de87904b65b2da2 to your computer and use it in GitHub Desktop.

Select an option

Save souzagab/0ae60e61939d51385de87904b65b2da2 to your computer and use it in GitHub Desktop.
Install OpenSSL 1.0.2 via Homebrew ( Fix for older Ruby Versions )

How to fix openSSL incompatibility issues in older Ruby Versions. (<=2.3)

Homebrew

Install openssl 1.0.2 via homebrew :

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/64555220bfbf4a25598523c2e4d3a232560eaad7/Formula/openssl.rb -f

This should install openssl in /usr/local/opt/openssl

If you already have 1.1 installed, you should have 2 versions of opensll in: /user/local/opt/

  • openssl@1.1
  • openssl (1.0)

RVM

Install or Reinstall the version you want, but you must do it with --with-openssl-dir and pass the path of openssl (1.0).
In my case is /usr/local/opt/openssl

rvm install YOUR-RUBY-VERSION  --with-openssl-dir='/usr/local/opt/openssl'
@EliKazap
Copy link
Copy Markdown

EliKazap commented Jul 24, 2020

For ubuntu 20.04, follow these steps to install openssl 1.0:

  • Edit /etc/apt/sources.list and add this at the end of the file: deb http://security.ubuntu.com/ubuntu bionic-security main
  • Run sudo apt-get update && apt-cache policy libssl1.0-dev
  • Run sudo apt-get install libssl1.0-dev

Then run the RVM command with your openssl1.0 dir (/usr/local/ssl/bin here, you can check if the version is correct with ./usr/local/ssl/bin/openssl version):
rvm install YOUR-RUBY-VERSION --with-openssl-dir='/usr/local/ssl/bin'

@souzagab
Copy link
Copy Markdown
Author

For ubuntu 20.04, follow these steps to install openssl 1.0:

  • Edit /etc/apt/sources.list and add this at the end of the file: deb http://security.ubuntu.com/ubuntu bionic-security main
  • Run sudo apt-get update && apt-cache policy libssl1.0-dev
  • Run sudo apt-get install libssl1.0-dev

Then run the RVM command with your openssl1.0 dir (/usr/local/ssl/bin here, you can check if the version is correct with ./usr/local/ssl/bin/openssl version):
rvm install YOUR-RUBY-VERSION --with-openssl-dir='/usr/local/ssl/bin'

Also for asdf:

After installing libssl1.0

PKG_CONFIG_PATH=/usr/lib/openssl-1.0/pkgconfig \
RUBY_EXTRA_CONFIGURE_OPTIONS="--with-openssl-dir=/usr/lib/openssl-1.0" \
asdf install YOUR-RUBY-VERSION

@Leonardo-Figueiredo
Copy link
Copy Markdown

For rbenv

RUBY_CONFIGURE_OPTS=--with-openssl-dir=/home/linuxbrew/.linuxbrew/Cellar/openssl@1.1/1.1.1o/ rbenv install

@alpacin0
Copy link
Copy Markdown

For Ubuntu 22.04 LTS on WSL none of those worked for me. Somehow it will add openssl 3.0 to my ruby installs.
Fortunately this did the trick:

rvm pkg install openssl
rvm remove your-ruby-version
rvm install 2.7.2 --with-openssl-dir=$HOME/.rvm/usr

The first line will install openssl 1.0.1i on your .rvm folder (yes didn't expect that. That's the magic trick)
I add the 'rvm remove' because I previously installed ruby. So I preferred a clean install.
Install your desired version and it will be linked correctly to the openssl 1.0.1i folder.
Now confirm the openssl version Ruby has:
ruby -ropenssl -e 'puts OpenSSL::OPENSSL_LIBRARY_VERSION'

ruby2-7-openssl1-0-ubu22-04lts

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