This is based on origina PR with official patches which landed in [ruby/openssl](https://github.com/ruby/openssl) repository and should reflect the state of OpenSSL 3 support in Ruby 3.1. Resolves: rhbz#1952925
Related: rhbz#2049693