ArticlesRocky Linux

Configuring Entropy on CentOS7/RockyLinux8 for FIPS OpenSSL

Introduction

The key to this problem is entropy. The FIPS openssl version is built with strict requirements for entropy to provide the necessary security guarantees: it fills up "pools" of truly random numbers when it starts up. If these pools aren't filled, then applications that call the openssl library will block until it can gather enough random material to proceed. Regular openssl doesn't do this: if it can't get enough true randomness, it uses fuzzy pseudorandomness and continues. It is important to understand that FIPS is not meant to be run in pieces. It is a holistic system. The kernel provides the entropy to the openssl library via a system call.

The RHEL/Rocky 9 kernel (and upstream 5.10, 5.15, etc. kernels) seem to provide enough entropy more or less built-in. CentOS 7 (kernel 3.10.0) and RHEL/Rocky 8 (kernel 4.18) do not in some cases.

Problem

When using openssl fips package on a CentOS/Rocky 8 system you may see the following timeouts when using dnf with the FIPS openssl libraries installed:

dnf list
Rocky Linux BaseOS         0.0  B/s |   0  B     17:45
Errors during downloading metadata for repository 'baseos':
 - Curl error (28): Timeout was reached for https://.../BaseOS/x86_64/os/repodata/repomd.xml [SSL connection timeout]
 - Curl error (28): Timeout was reached for https://.../BaseOS/x86_64/os/repodata/repomd.xml [Operation timed out after 99165 milliseconds with 0 out of 0 bytes received]
Error: Failed to download metadata for repo 'baseos': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried

Also, sshd may freeze on startup, preventing remote access to a system.

Resolution

Fortunately, the solution is simple: On any CentOS 7/Rocky 8 host, if you want to run containers with the FIPS openssl library installed, you need to do this (on the host, not inside the Rocky 8 container):

yum install rng-tools

systemctl enable --now rngd

The rngd daemon feeds extra, hardware generated, high-quality sources of entropy into the kernel, thus preventing the entropy pool from becoming exhausted.