‘RSA_SSLV23_PADDING’ undeclared (first use in this function); did you mean ‘RSA_NO_PADDING’? While compiling ruby-2.7.1 using asdf
Asked Answered
T

5

15

I am getting this issue while compiling ruby-2.7.1 using asdf or rvm.

It is even causing issues in erlang installation as well.

Error could be

generating x86_64-linux-fake.rb
x86_64-linux-fake.rb updated
./miniruby -I./lib -I. -I.ext/common  ./tool/runruby.rb --extout=.ext  -- --disable-gems -r./x86_64-linux-fake ./tool/rbinstall.rb --make="make" --dest-dir="" --extout=".ext" --mflags="" --make-flags="" --data-mode=0644 --prog-mode=0755 --installed-list .installed.list --mantype="doc" --rdoc-output=".ext/rdoc" --html-output=".ext/html"
/tmp/ruby-build.20220515222647.5893.R2e2fF/ruby-2.7.1/lib/rubygems/core_ext/kernel_require.rb:92:in `require': libssl.so.1.1: cannot open shared object file: No such file or directory - /tmp/ruby-build.20220515222647.5893.R2e2fF/ruby-2.7.1/.ext/x86_64-linux/openssl.so (LoadError)
    from /tmp/ruby-build.20220515222647.5893.R2e2fF/ruby-2.7.1/lib/rubygems/core_ext/kernel_require.rb:92:in `require'
    from /tmp/ruby-build.20220515222647.5893.R2e2fF/ruby-2.7.1/.ext/common/openssl.rb:13:in `<top (required)>'
    from /tmp/ruby-build.20220515222647.5893.R2e2fF/ruby-2.7.1/lib/rubygems/core_ext/kernel_require.rb:92:in `require'
    from /tmp/ruby-build.20220515222647.5893.R2e2fF/ruby-2.7.1/lib/rubygems/core_ext/kernel_require.rb:92:in `require'
    from /tmp/ruby-build.20220515222647.5893.R2e2fF/ruby-2.7.1/lib/rubygems/security.rb:12:in `<top (required)>'
    from /tmp/ruby-build.20220515222647.5893.R2e2fF/ruby-2.7.1/lib/rubygems/core_ext/kernel_require.rb:92:in `require'
    from /tmp/ruby-build.20220515222647.5893.R2e2fF/ruby-2.7.1/lib/rubygems/core_ext/kernel_require.rb:92:in `require'
    from /tmp/ruby-build.20220515222647.5893.R2e2fF/ruby-2.7.1/lib/rubygems/package.rb:44:in `<top (required)>'
    from /tmp/ruby-build.20220515222647.5893.R2e2fF/ruby-2.7.1/lib/rubygems/core_ext/kernel_require.rb:92:in `require'
    from /tmp/ruby-build.20220515222647.5893.R2e2fF/ruby-2.7.1/lib/rubygems/core_ext/kernel_require.rb:92:in `require'
    from /tmp/ruby-build.20220515222647.5893.R2e2fF/ruby-2.7.1/lib/rubygems/installer.rb:11:in `<top (required)>'
    from /tmp/ruby-build.20220515222647.5893.R2e2fF/ruby-2.7.1/lib/rubygems/core_ext/kernel_require.rb:92:in `require'
    from /tmp/ruby-build.20220515222647.5893.R2e2fF/ruby-2.7.1/lib/rubygems/core_ext/kernel_require.rb:92:in `require'
    from ./tool/rbinstall.rb:713:in `<module:RbInstall>'
    from ./tool/rbinstall.rb:649:in `<main>'
make: *** [uncommon.mk:373: do-install-all] Error 1

OR

ossl_pkey_rsa.c:877:58: error: ‘RSA_SSLV23_PADDING’ undeclared (first use in this function); did you mean ‘RSA_NO_PADDING’?
  877 | #define DefRSAConst(x) rb_define_const(cRSA, #x, INT2NUM(RSA_##x))
      |                                                          ^~~~
../.././include/ruby/ruby.h:262:33: note: in definition of macro ‘RB_INT2FIX’
  262 | #define RB_INT2FIX(i) (((VALUE)(i))<<1 | RUBY_FIXNUM_FLAG)
      |                                 ^
../.././include/ruby/ruby.h:1609:20: note: in expansion of macro ‘RB_INT2NUM’
 1609 | #define INT2NUM(x) RB_INT2NUM(x)
      |                    ^~~~~~~~~~
ossl_pkey_rsa.c:877:50: note: in expansion of macro ‘INT2NUM’
  877 | #define DefRSAConst(x) rb_define_const(cRSA, #x, INT2NUM(RSA_##x))
      |                                                  ^~~~~~~
ossl_pkey_rsa.c:942:5: note: in expansion of macro ‘DefRSAConst’
  942 |     DefRSAConst(SSLV23_PADDING);
      |     ^~~~~~~~~~~
ossl_pkey_rsa.c:877:58: note: each undeclared identifier is reported only once for each function it appears in
  877 | #define DefRSAConst(x) rb_define_const(cRSA, #x, INT2NUM(RSA_##x))
      |                                                          ^~~~
../.././include/ruby/ruby.h:262:33: note: in definition of macro ‘RB_INT2FIX’
  262 | #define RB_INT2FIX(i) (((VALUE)(i))<<1 | RUBY_FIXNUM_FLAG)
      |                                 ^
../.././include/ruby/ruby.h:1609:20: note: in expansion of macro ‘RB_INT2NUM’
 1609 | #define INT2NUM(x) RB_INT2NUM(x)
      |                    ^~~~~~~~~~
ossl_pkey_rsa.c:877:50: note: in expansion of macro ‘INT2NUM’
  877 | #define DefRSAConst(x) rb_define_const(cRSA, #x, INT2NUM(RSA_##x))
      |                                                  ^~~~~~~
ossl_pkey_rsa.c:942:5: note: in expansion of macro ‘DefRSAConst’
  942 |     DefRSAConst(SSLV23_PADDING);
      |     ^~~~~~~~~~~
ossl_pkey.c: At top level

I tried installing openssl version 1.1 using apt-get but it is not working.

Thankyou answered 15/5, 2022 at 17:28 Comment(0)
F
11

I usually use a solution like this when I encounter openssl issues while compiling Ruby. I prefer not to mess with the OS's installed version if I can help it, and I don't use anything like RVM.

  1. Download the latest version ~1.1 of Open SSL:
wget https://www.openssl.org/source/openssl-1.1.1q.tar.gz
  1. Extract and configure to install somewhere on your system, then compile and install. In my case it goes in my home dir since I do a lot of Ruby development and ruby is also going in my home dir.
tar xvzf openssl-1.1.1q.tar.gz
cd openssl-1.1.1q
mkdir -p $HOME/lib/openssl
./config --prefix=$HOME/lib/openssl
make
make install
  1. Make sure your openssl folder has the proper certs.
cp /etc/ssl/certs/* $HOME/lib/openssl/ssl/certs
  1. Compile ruby like so. Remember that this is specific for my own home directory, you could just as easily install this as a systemwide ruby.
tar xvzf ruby-2.7.1.tar.gz
cd ruby-2.7.1
./configure --prefix=$HOME/.rubies/ruby-2.7.1 --with-openssl-dir=$HOME/lib/openssl
make
make install
Frosty answered 29/9, 2022 at 19:19 Comment(1)
Should be cp -r /etc/ssl/certs/* $HOME/lib/openssl/ssl/certs, but great answer! Thanks!Cantabile
T
5

Openssl recently removed support for RSA_SSLV23_PADDING after CVE-2021-23839

Best option is installing latest version of ruby, which should have support for this, but I had to install this particular version of ruby. So here are the things that helped me.

This answer really helped me. https://askubuntu.com/questions/1126893/how-to-install-openssl-1-1-1-and-libssl-package

And in the last I have to copy this openssl.so.1.1 file (generated after compiling) to lib folder.

sudo cp openssl.so.1.1 /usr/local/lib/

or

sudo cp openssl.so.1.1 /usr/local/lib64/

then export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 and sudo ldconfig

Now try to run asdf install ruby-2.7.1

It should be working.

Thankyou answered 15/5, 2022 at 17:28 Comment(1)
RSA_SSLV23_PADDING was removed in 3.0.0 I guess. Or see the changelog (Changes between 1.1.1 and 3.0.0 [7 sep 2021], Removed RSA padding mode for SSLv23).Hearsh
M
2

If you run into this issue while attempting to install an older version of Ruby with asdf on macOS, there's no need to uninstall openssl@3 or build OpenSSL yourself.

Make sure you have [email protected] installed with Homebrew (brew install [email protected]); it can live alongside openssl@3 without any problems. Then, set the PKG_CONFIG_PATH variable to the location of the pkg-confg *.pc files for [email protected] when using asdf to install Ruby.

For example:

PKG_CONFIG_PATH="$(brew --prefix [email protected])/lib/pkgconfig" \
  asdf install ruby 3.0.2

This should allow you to install Ruby without getting the "use of undeclared identifier 'RSA_SSLV23_PADDING'" errors.

Mosher answered 10/2 at 20:33 Comment(0)
S
1

Found simple solution here: https://github.com/rvm/rvm/issues/5216#issuecomment-1206488598

You need to:

rvm pkg install openssl

and then run:

rvm install ruby-2.7.3 --with-openssl-dir=/usr/share/rvm/usr

Ruby will be compiled using internal rvm openssl in version 1.0.2, so no longer RSA_SSLV23_PADDING error.

Soon after posting this answer I found out that there are some issues when using ruby 2.7.x compiled with openssl 1.0.2. I experienced issues with installing/running pq gem due to mismatching openssl versions (this gem uses 1.1.1).

There were not such problems when ruby has been compiled with openssl 1.1.1, so I strongly recommend to look at Jon Jenkins answer.

Summon answered 29/8, 2022 at 10:16 Comment(2)
Good solution! I needed to use rvm pkg install openssl.Flanker
Should it not be --with-openssl-dir=$HOME/.rvm/usr ?Unidirectional
H
0

Fresh to ruby, try everything finally solved:

  1. brew uninstall openssl@3 to remove invalid openssl version.

  2. brew install [email protected] to install openssl with 1.1 version.

Homophone answered 2/7, 2023 at 14:17 Comment(1)
This might work, but is very much not recommended. You might break a bunch of other stuff by downgrading from openssl v3. You should try install openssl 1.1 separately and link to it on the build configuration, as recommended on other answers.Pellitory

© 2022 - 2024 — McMap. All rights reserved.