Bllergh. This is a real pain.
The openssl extension that ships with ruby 3.0 only compiles against openssl <= 1.1, but now openssl 3.0 is shipped in debian testing/unstable.
Ruby bug here: https://bugs.ruby-lang.org/issues/18658
Version >= 3.0 of the openssl rubygem does compile against openssl 3.0 though.
I use rbenv to manage ruby versions on my system, which uses ruby-build to manage installs.