Fix use of `MOSQ_OPT_TLS_ENGINE` being unable to be used.

This was due to the openssl ctx not being initialised until starting to connect.

Closes #2537. Thanks to chessing-c4.
pull/2621/head
Roger A. Light 3 years ago
parent 127c5e7577
commit b6b8039914

@ -11,6 +11,8 @@ Broker:
Client library: Client library:
- Fix threads library detection on Windows under cmake. Bumps the minimum - Fix threads library detection on Windows under cmake. Bumps the minimum
cmake version to 3.1, which is still ancient. cmake version to 3.1, which is still ancient.
- Fix use of `MOSQ_OPT_TLS_ENGINE` being unable to be used due to the openssl
ctx not being initialised until starting to connect. Closes #2537.
Clients: Clients:
- Fix mosquitto_pub incorrectly reusing topic aliases when reconnecting. - Fix mosquitto_pub incorrectly reusing topic aliases when reconnecting.

@ -1565,6 +1565,9 @@ libmosq_EXPORT int mosquitto_int_option(struct mosquitto *mosq, enum mosq_opt_t
* MOSQ_OPT_TLS_ENGINE - Configure the client for TLS Engine support. * MOSQ_OPT_TLS_ENGINE - Configure the client for TLS Engine support.
* Pass a TLS Engine ID to be used when creating TLS * Pass a TLS Engine ID to be used when creating TLS
* connections. Must be set before <mosquitto_connect>. * connections. Must be set before <mosquitto_connect>.
* Must be a valid engine, and note that the string will not be used
* until a connection attempt is made so this function will return
* success even if an invalid engine string is passed.
* *
* MOSQ_OPT_TLS_KEYFORM - Configure the client to treat the keyfile * MOSQ_OPT_TLS_KEYFORM - Configure the client to treat the keyfile
* differently depending on its type. Must be set * differently depending on its type. Must be set

@ -284,6 +284,8 @@ int mosquitto_string_option(struct mosquitto *mosq, enum mosq_opt_t option, cons
switch(option){ switch(option){
case MOSQ_OPT_TLS_ENGINE: case MOSQ_OPT_TLS_ENGINE:
#if defined(WITH_TLS) && !defined(OPENSSL_NO_ENGINE) #if defined(WITH_TLS) && !defined(OPENSSL_NO_ENGINE)
mosquitto__free(mosq->tls_engine);
if(value){
eng = ENGINE_by_id(value); eng = ENGINE_by_id(value);
if(!eng){ if(!eng){
return MOSQ_ERR_INVAL; return MOSQ_ERR_INVAL;
@ -293,6 +295,7 @@ int mosquitto_string_option(struct mosquitto *mosq, enum mosq_opt_t option, cons
if(!mosq->tls_engine){ if(!mosq->tls_engine){
return MOSQ_ERR_NOMEM; return MOSQ_ERR_NOMEM;
} }
}
return MOSQ_ERR_SUCCESS; return MOSQ_ERR_SUCCESS;
#else #else
return MOSQ_ERR_NOT_SUPPORTED; return MOSQ_ERR_NOT_SUPPORTED;

Loading…
Cancel
Save