I encountered the same openssl error on Fedora when trying to use gem install . It seems you need to install additional packages with yum/dnf
sudo dnf install rubygems rubygem-bundler ruby-devel mariadb-devel
After running the above command, gem install should now work.