How can I install the ruby gem openssl version 2.2.1

I was just forced to install the openssl gem because I needed a newer version than ships with ruby. Locally, for our docker environment, it works like a charm. However, on CircleCI it fails with the below message. Any help greatly appreciated.

Installing openssl 2.2.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/home/circleci/repo/vendor/bundle/ruby/2.3.0/gems/openssl-2.2.1/ext/openssl
/usr/local/bin/ruby -I /usr/local/lib/ruby/site_ruby/2.3.0 -r
./siteconf20220531-177-15ajnpq.rb extconf.rb
checking for t_open() in -lnsl... no
checking for socket() in -lsocket... no
checking for openssl/ssl.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/usr/local/bin/$(RUBY_BASE_NAME)
	--with-openssl-dir
	--without-openssl-dir
	--with-openssl-include
	--without-openssl-include=${openssl-dir}/include
	--with-openssl-lib
	--without-openssl-lib=${openssl-dir}/lib
	--with-kerberos-dir
	--without-kerberos-dir
	--with-kerberos-include
	--without-kerberos-include=${kerberos-dir}/include
	--with-kerberos-lib
	--without-kerberos-lib=${kerberos-dir}/lib
	--with-debug
	--without-debug
	--enable-debug
	--disable-debug
	--with-nsllib
	--without-nsllib
	--with-socketlib
	--without-socketlib
	--with-openssl-config
	--without-openssl-config
	--with-pkg-config
	--without-pkg-config
extconf.rb:98:in `<main>': OpenSSL library could not be found. You might want to
use --with-openssl-dir=<dir> option to specify the prefix where OpenSSL is
installed. (RuntimeError)

To see why this extension failed to compile, please check the mkmf.log which can
be found here:

/home/circleci/repo/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/openssl-2.2.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in
/home/circleci/repo/vendor/bundle/ruby/2.3.0/gems/openssl-2.2.1 for inspection.
Results logged to
/home/circleci/repo/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/openssl-2.2.1/gem_make.out

An error occurred while installing openssl (2.2.1), and Bundler cannot
continue.
Make sure that `gem install openssl -v '2.2.1' --source 'https://rubygems.org/'`
succeeds before bundling.

In Gemfile:
  openssl

Exited with code exit status 5
CircleCI received exit code 5