Skip to content

Commit bbf385b

Browse files
committed
Fix OpenSSL config loading race condition for TLS engines
When setting MOSQ_OPT_TLS_ENGINE, mosquitto_string_option() initializes the OpenSSL singleton via OPENSSL_init_crypto but omits the OPENSSL_INIT_LOAD_CONFIG flag. If an engine is set before mosquitto_connect_async() (which calls net__init_tls()), OpenSSL locks its initialization state without reading openssl.cnf. This causes engines like pkcs11 to fail to resolve their MODULE_PATH, resulting in dlopen failures for hardware TrustZone/HSM modules. Adding OPENSSL_INIT_LOAD_CONFIG to the engine initialization ensures the configuration is parsed and the engine can locate its dynamic backend. Signed-off-by: Jack(Boliang) Ma <jack.boliang.ma106@gmail.com>
1 parent bb56477 commit bbf385b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/options.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ int mosquitto_string_option(struct mosquitto *mosq, enum mosq_opt_t option, cons
295295
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
296296
/* The "Dynamic" OpenSSL engine is not initialized by default but
297297
is required by ENGINE_by_id() to find dynamically loadable engines */
298-
OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_DYNAMIC, NULL);
298+
OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_DYNAMIC | OPENSSL_INIT_ENGINE_DYNAMIC, NULL);
299299
#endif
300300
eng = ENGINE_by_id(value);
301301
if(!eng){

0 commit comments

Comments
 (0)