Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIPS / build] Optimize FIPS image size / build process. Fix OpenSSL target. #183204

Merged
merged 2 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
##########################################################################

nodejs_conf = nodejs_init
.include /usr/local/ssl/fipsmodule.cnf
.include /usr/share/kibana/openssl/ssl/fipsmodule.cnf

[nodejs_init]
providers = provider_sect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,26 +127,28 @@ WORKDIR /usr/share/kibana
# https://github.com/openssl/openssl/blob/openssl-3.0/README-FIPS.md
# https://www.openssl.org/docs/man3.0/man7/fips_module.html

# Ideally we would handle this in the builder step, but make is installing over the OS version
# of OpenSSL and requires linking of many submodules.
# Ideally we would handle this in the builder step, but OpenSSL requires linking of many submodules.
RUN set -e ; \
curl --retry 8 -S -L -O https://www.openssl.org/source/openssl-3.0.8.tar.gz ; \
curl --retry 8 -S -L -O https://www.openssl.org/source/openssl-3.0.8.tar.gz.sha256 ; \
echo "$(cat openssl-3.0.8.tar.gz.sha256) openssl-3.0.8.tar.gz" | sha256sum -c ; \
tar -zxf openssl-3.0.8.tar.gz ; \
rm -rf openssl-3.0.8.tar* ; \
cd /usr/share/kibana/openssl-3.0.8 ; \
./Configure enable-fips ; \
make -j $(nproc) ; \
make install ; \
ldconfig /usr/local/lib64/ ; \
chown -R 1000:0 /usr/share/kibana/openssl-3.0.8
OPENSSL_VERSION='3.0.8'; \
OPENSSL_PATH=/usr/share/kibana/openssl ; \
mkdir "${OPENSSL_PATH}"; \
curl --retry 8 -S -L -O "https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz" ; \
curl --retry 8 -S -L -O "https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz.sha256" ; \
echo "$(cat openssl-${OPENSSL_VERSION}.tar.gz.sha256) openssl-${OPENSSL_VERSION}.tar.gz" | sha256sum -c ; \
tar -zxf "openssl-${OPENSSL_VERSION}.tar.gz" ; \
rm -rf openssl-${OPENSSL_VERSION}.tar* ; \
cd "/usr/share/kibana/openssl-${OPENSSL_VERSION}" ; \
./Configure --prefix="${OPENSSL_PATH}" --openssldir="${OPENSSL_PATH}/ssl" --libdir="${OPENSSL_PATH}/lib" enable-fips; \
make -j $(nproc) > /dev/null ; \
make install > /dev/null ; \
rm -rf "/usr/share/kibana/openssl-${OPENSSL_VERSION}" ; \
Comment on lines +141 to +144
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit hard to see in the diff, these are the main changes.

chown -R 1000:0 "${OPENSSL_PATH}";

# Enable FIPS for Kibana only. In the future we can override OS wide with ENV OPENSSL_CONF
RUN /usr/bin/echo -e '\n--enable-fips' >> config/node.options
RUN /usr/bin/echo '--openssl-config=/usr/share/kibana/openssl-3.0.8/nodejs.cnf' >> config/node.options
COPY --chown=1000:0 openssl/nodejs.cnf /usr/share/kibana/openssl-3.0.8/nodejs.cnf
ENV OPENSSL_MODULES=/usr/local/lib64/ossl-modules
RUN /usr/bin/echo '--openssl-config=/usr/share/kibana/config/nodejs.cnf' >> config/node.options
COPY --chown=1000:0 openssl/nodejs.cnf "/usr/share/kibana/config/nodejs.cnf"
ENV OPENSSL_MODULES=/usr/share/kibana/openssl/lib/ossl-modules

{{/fips}}
RUN ln -s /usr/share/kibana /opt/kibana
Expand Down