Skip to content

Commit 47b843c

Browse files
committed
common: disable OpenSSL engine support if it is disabled
OpenSSL 3.0 documentation recommends moving from the ENGINE API to the Providers API. Recent distributions may compile OpenSSL without engine support by default, necessitating more flexible configuration handling. So, in this change: - Add a CMake option `WITH_OPENSSL_ENGINE` to explicitly control engine support - Respect `openssl_engine_opts` when engine support is enabled - Provide clear error messaging when engine options are set but support is disabled See also: - OpenSSL 3.0 documentation: https://wiki.openssl.org/index.php/OpenSSL_3.0#Engines_and_.22METHOD.22_APIs Fixes: https://tracker.ceph.com/issues/68059 Signed-off-by: Kefu Chai <[email protected]>
1 parent ec1feb7 commit 47b843c

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

cmake/modules/CephChecks.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ if(LINUX)
5555
CHECK_INCLUDE_FILES("sched.h" HAVE_SCHED)
5656
endif()
5757
CHECK_INCLUDE_FILES("valgrind/helgrind.h" HAVE_VALGRIND_HELGRIND_H)
58+
CHECK_INCLUDE_FILES("openssl/engine.h" HAVE_OPENSSL_ENGINE_H)
59+
option(WITH_OPENSSL_ENGINE "Build with OpenSSL Engine Support")
60+
if(WITH_OPENSSL_ENGINE AND NOT HAVE_OPENSSL_ENGINE)
61+
message(FATAL_ERROR "Can't find openssl/engine.h")
62+
endif()
5863

5964
include(CheckTypeSize)
6065
set(CMAKE_EXTRA_INCLUDE_FILES "linux/types.h" "netinet/in.h")

src/common/openssl_opts_handler.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
#include <openssl/bio.h>
1818
#include <openssl/conf.h>
19+
#ifndef OPENSSL_NO_ENGINE
1920
#include <openssl/engine.h>
21+
#endif
2022
#include <mutex>
2123
#include <vector>
2224
#include <algorithm>
@@ -40,6 +42,9 @@ static ostream &_prefix(std::ostream *_dout)
4042
{
4143
return *_dout << "OpenSSLOptsHandler: ";
4244
}
45+
46+
#ifndef OPENSSL_NO_ENGINE
47+
4348
// -----------------------------------------------------------------------------
4449

4550
string construct_engine_conf(const string &opts)
@@ -128,15 +133,20 @@ void load_module(const string &engine_conf)
128133
log_error("failed to load modules from CONF:\n" + get_openssl_error());
129134
}
130135
}
136+
#endif // !OPENSSL_NO_ENGINE
131137

132138
void init_engine()
133139
{
134140
string opts = g_ceph_context->_conf->openssl_engine_opts;
135141
if (opts.empty()) {
136142
return;
137143
}
144+
#ifdef OPENSSL_NO_ENGINE
145+
derr << "OpenSSL is compiled with no engine, but openssl_engine_opts is set" << dendl;
146+
#else
138147
string engine_conf = construct_engine_conf(opts);
139148
load_module(engine_conf);
149+
#endif
140150
}
141151

142152
void ceph::crypto::init_openssl_engine_once()

0 commit comments

Comments
 (0)