Found the solution
WHY this issue was coming:
Docker build (to create the image) was run on a machine (the other machine, where cmake was working inside the docker container)... i.e. where FIPS was not installed.
During the build step, Docker file was running
zypper install cmake
(or yum install cmake
).
As FIPS was disabled on the machine where docker image was built, cmake was installed in docker image, without understanding FIPS being enabled / dracut-fips being installed.
Then, when you copy this image and consume it on a machine where FIPS is actually ENABLED, then cmake was failing with that error mesg: crypto/fips/fips.c:153: OpenSSL internal error: FATAL FIPS SELFTEST FAILURE
Actually there are 2 solutions.
--
Solution #1: Tag your docker image appropriately.
Summary:
PS: If you do install cmake using the above, then it'll only work on target machine where you run container, if that machine's FIPS is disabled or enabled at build time. i.e. if FIPS was enabled, you install cmake and run it on a machine where it's NOT same FIPS setting as the host, where image was built, then you'll be reading this post for help.
Better way in case you want to install cmake using the above package managers, would be, tag your docker image appropriately during image creation time i.e.:
docker build -t <image-name>-fips-enabled ...
if FIPS is enabled
and
docker build -t <image-name>-fips-disabled ...
if FIPS on that that machine is disabled.
That way, you can pick the correct docker image imagename-fips-enabled vs imagename-fips-disabled acc. to what your target machine FIPS setting is (where you'll actually perform docker run ...
using this image).
--
Solution #2: Don't use zypper (OpenSuse) or yum if you have RedHat container.
and this solution is flexible in the sense, that it's independent of FIPS setting = 0 / 1 on the host, where image was built.
I didn't use zypper
/yum
to install cmake
inside Dockerfile
, but just grabbed cmake-3.18.2-Linux-x86_64.tar.gz bundle file.
Within Dockerfile, I simply extracted this .tar.gz file inside some directory.
Also I set export PATH:/path/where/I/installed/cmake-3.18.2../bin:/..some_other_paths:/...:/....
in Dockerfile inside RUN statement.
i.e.
RUN export PATH=/path/where/I/installed/cmake-3.18.2../bin:/...... && <more cmds here> && <some other cmds here> && ... etc
, so it can find the extracted cmake 3.18.2 for any buil-time (cmake operations) and also SET the same PATH=/... variable as ENV PATH=/.... same value used during RUN for PATH
so at runtime, when the container runs, $PATH is all set for finding cmake
(3.18.2 version) rather than using any existing /usr/bin/cmake or some other shit
).
Dockerfile snapshot:
# curl -k -sSf -H "X-JFrog-Art-Api:dslfhjlieurqwihlj233lk2l4j6p9usdkajdfasddl809842iijhlkhflhafOHIHFLyeaGoodLuck" \
# -o /tmp/cmake.tar.gz https://artifactory.company.com/artifactory/some-Local/cmake/cmake-3.18.2-Linux-x86_64.tar.gz && \
and
as my umask settings were set to 022, I didn't have to do any chicken chmod operation post untar:
# echo -e "\n-- Installing CMake ...\n" && \
# tar -xvzpf /tmp/cmake.tar.gz -C /home/docker_nonroot_user/tools/ && \
Inside the docker container, as ENV PATH=/...
was set in Dockerfile for this target path as well, the correct cmake
3.18.2 was used at docker container runtime action.
cmake installed location in my case was:
/home/docker_nonroot_user/tools/cmake-3.18.2-Linux-x86_64/bin/cmake
PATH inside docker container was:
/home/docker_nonroot_user/tools/cov-analysis/bin:/home/docker_nonroot_user/tools/cmake-3.18.2-Linux-x86_64/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RESULT:
Using a Docker image built using SOLUTION #2 above, i.e. docker image built on a machine where FIPS = 0 aka DISABLED and then later, using this same image to create a container on a totally different target host machine where FIPS = 1 aka ENABLED, I see:
87d8104d8c41:/home/docker_nonroot_user # sysctl -a|grep fips_en
crypto.fips_enabled = 1
87d8104d8c41:/home/docker_nonroot_user #
87d8104d8c41:/home/docker_nonroot_user # which cmake
/usr/bin/cmake
87d8104d8c41:/home/docker_nonroot_user #
87d8104d8c41:/home/docker_nonroot_user # cmake --version
crypto/fips/fips.c:153: OpenSSL internal error: FATAL FIPS SELFTEST FAILURE
Aborted (core dumped)
87d8104d8c41:/home/docker_nonroot_user #
87d8104d8c41:/home/docker_nonroot_user #
87d8104d8c41:/home/docker_nonroot_user # ls -l /home/docker_nonroot_user/tools/cmake-3.18.2-Linux-x86_64/bin
total 75504
-rwxr-xr-x 1 root root 11908568 Aug 20 2020 ccmake
-rwxr-xr-x 1 root root 12096216 Aug 20 2020 cmake
-rwxr-xr-x 1 root root 27476480 Aug 20 2020 cmake-gui
-rwxr-xr-x 1 root root 12398808 Aug 20 2020 cpack
-rwxr-xr-x 1 root root 13318712 Aug 20 2020 ctest
87d8104d8c41:/home/docker_nonroot_user #
87d8104d8c41:/home/docker_nonroot_user # ls -l /home/docker_nonroot_user/tools/cmake-3.18.2-Linux-x86_64/bin/cmake
-rwxr-xr-x 1 root root 12096216 Aug 20 2020 /home/docker_nonroot_user/tools/cmake-3.18.2-Linux-x86_64/bin/cmake
87d8104d8c41:/home/docker_nonroot_user #
87d8104d8c41:/home/docker_nonroot_user # /home/docker_nonroot_user/tools/cmake-3.18.2-Linux-x86_64/bin/cmake --version
cmake version 3.18.2
CMake suite maintained and supported by Kitware (kitware.com/cmake).
87d8104d8c41:/home/docker_nonroot_user # : Merry X-mas Baaaaeeebyyy! - no more FIPS shit error now. Next I'll fix some chown on ~<user> and close my story.
SOLUTION #3: You can disable FIPS but only if you are allowed to do so, then you don't need solution #1 or solution #2.