If you are using RVM for managing Ruby, you can install the correct versions with
rvm pkg install openssl
Then run your Ruby installation again.