2

I want to have two different OpenSSL versions in my OS. Right now, openssl version -v returns

OpenSSL 1.1.1f 31 Mar 2020

I want to have OpenSSL 1.0.2 as well, for I need to install Ruby 2.2.10 with rbenv, and for versions under 2.4 it requires an OpenSSL downgrade.

How to install openssl 1.0.2 with default openssl (1.1.1) on Ubuntu 16.04? - I've followed monaye's answer in this thread, and managed to have OpenSSL installed: openssl version -v

OpenSSL 1.0.2l 25 May 2017

but having the OS use OpenSSL might conflict my Ruby 3.0.0 app, because I need to have both ssl versions available. This is why I have updated OpenSSL back to its latest version

rbenv's docs have a solution for this conflict in MacOS:

with Homebrew on macOS

brew install rbenv/tap/openssl@1.0 RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.0)" rbenv install 2.3.8

and I would need something similar in Ubuntu 20.04 - is it possible?

In the rbenv forums, below OpenSSL version compatibility it says:

When building Ruby 2.3 or older, you must ensure that OpenSSL 1.0 is available somewhere on the system and point to it via the --with-openssl-dir configure flag. At the moment, most Linux distributions that come with OpenSSL 1.1 have a separate package for OpenSSL 1.0.

But

RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.0)" rbenv install 2.3.8

Fails: Command 'brew' not found

cratag
  • 31
  • So ... where is brew installed? Either you have it not installed or it is not in the PATH and that would require you to add an absolute path. – Rinzwind Mar 22 '21 at 15:16
  • Sorry, im new to Linux. I don't have brew, and I thought it was a MacOS package. ´sudo apt install brew´ returns ´unable to locate package brew´ and ´brew´ returns similar package names: qbrew and brec.

    I am now trying to install brew

    – cratag Mar 22 '21 at 15:24
  • It is probably called linuxbrew ;-) Oh and a small note: you are probably better off installing Ubuntu in virtualbox and use the older ssl in there and not have 2 versions installed on 1 system. – Rinzwind Mar 22 '21 at 15:27
  • it failed after installing brew and openssl. BUILD FAILED (Ubuntu 20.04 using ruby-build 20210309)

    Inspect or clean up the working tree at /tmp/ruby-build.20210322123729.48434.WmdkHX Results logged to /tmp/ruby-build.20210322123729.48434.log

    – cratag Mar 22 '21 at 15:50
  • this is the log: https://drive.google.com/file/d/1RPDsWTgJ-bfh7G3iX64jGIY1iIK4fp-d/view – cratag Mar 22 '21 at 16:00

2 Answers2

1

This was the solution I found, and with a small tweak it worked. Thanks to EliKazap Edit /etc/apt/sources.list and add this at the end of the file: deb http://security.ubuntu.com/ubuntu bionic-security main

then

Run sudo apt-get update && apt-cache policy libssl1.0-dev

Run sudo apt-get install libssl1.0-dev

check if the version is correct with ./usr/local/ssl/bin/openssl version

and then

RUBY_CONFIGURE_OPTS="--with-openssl-dir='/usr/local/ssl/bin'" rbenv install 2.2.10
cratag
  • 31
0

The standard --with-openssl-dir solution works great if you compiled openssl in a standard way, but in some linux distros they have multiple versions of openssl that have been compiled in non-standard ways. For example, EPEL provides openssl11 on RHEL/CentOS 7. I was able to compile against it using:

RUBY_CONFIGURE_OPTS='--with-openssl-dir=/usr/include/openssl11 --with-openssl-lib=/usr/lib64/openssl11 --with-openssl-include=/usr/include/openssl11' rbenv install 3.2.2