Skip to content

Allow OpenSSL FIPS mode - #78413

Closed
thevar1able wants to merge 20 commits into
masterfrom
openssl-fips-oss
Closed

thevar1able wants to merge 20 commits into
masterfrom
openssl-fips-oss

Conversation

@thevar1able

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Remove legacy OpenSSL API usage and update CMake to support FIPS mode

@clickhouse-gh

clickhouse-gh Bot commented Mar 28, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [ae342b2]

@clickhouse-gh clickhouse-gh Bot added pr-improvement Pull request with some product improvements submodule changed At least one submodule changed in this PR. labels Mar 28, 2025
@rschu1ze rschu1ze self-assigned this Mar 29, 2025
Comment thread base/poco/Crypto/src/RSAKeyImpl.cpp Resolved
Comment thread base/poco/Crypto/src/RSAKeyImpl.cpp Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The functions below (e.g. RSA_generate_key_ex) seem deprecated in OSSL 3.x.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, all non-EVP_* seem to be deprecated. Should we get rid of RSAKey and ECKey from Poco?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If no other code within or outside Poco uses RSA/ECKey, then yes, let's remove it.

(as a general rule, the usage and even presence of Poco is discouraged)

Comment thread contrib/openssl-cmake/CMakeLists.txt Resolved
Comment thread src/Common/OpenSSLHelpers.cpp Resolved
Comment thread src/Common/OpenSSLHelpers.cpp Resolved
Comment thread src/Core/MySQL/Authentication.cpp Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I hope we have test coverage for this code :-)

Comment thread src/Functions/FunctionsHashing.h Resolved
@thevar1able

This comment was marked as outdated.

Comment thread src/Common/OpenSSLHelpers.cpp Resolved
Comment thread CMakeLists.txt
option(ENABLE_OPENSSL_DYNAMIC "This option removes SSL from ClickHouse and will link to the OpenSSL version supplied by OS." ${ENABLE_OPENSSL_DYNAMIC_DEFAULT})

set(ENABLE_OPENSSL_FIPS_DEFAULT OFF)
option(ENABLE_OPENSSL_FIPS "Allow using OpenSSL library in FIPS mode." ${ENABLE_OPENSSL_FIPS_DEFAULT})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Cosmetics: ENABLE_OPENSSL_FIPS = 1 forces FIPS (the initialization code in server/Server.cpp throws an exception if FIPS initialization fails). We should say in l. 481: "Enable FIPS mode in OpenSSL".

A more important question is where do we currently use the define?

  • to enable the FIPS mode in programs/keeper/Keeper.cpp and programs/server/Server.cpp (*)
  • to enable dynamic loading in programs/keeper/keeper_main.cpp and programs/main.cpp (**)

At least (*) could be made dependent on some server setting in the configuration file, e.g.

<enable_fips_mode>true</enable_fips_mode>

(side note: such a config tag ideally goes into the existing server section <openSSL><server>[...], see here)

Not sure if we can do a similar change to (**).

Not introducing a CMake define would simplify testing in CI as we could (in principle) use the general ClickHouse binary for testing.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

we could (in principle) use the general ClickHouse binary for testing

Nope, because of forbidden dlopen.

void OpenSSLInitializer::dynlockDestroy(struct CRYPTO_dynlock_value* lock, const char* file, int line)
{
delete lock;
if (--_rc == 0)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just paranoid ... could you check that the function in l. 61 is really called from somewhere during server shutdown?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yup
image

#if OPENSSL_VERSION_NUMBER >= 0x0907000L
OPENSSL_config(NULL);
#endif
SSL_library_init();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is l. 67-90 gone?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Outdated and considered harmful (explicitly setting rand seed).

Comment thread src/IO/WriteBufferFromS3.cpp Resolved
Comment thread src/Functions/FunctionsHashing.h Resolved
Comment thread src/Common/OpenSSLHelpers.h Resolved
@thevar1able thevar1able reopened this Apr 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants