Fix MOSQ_OPT_SSL_CTX not being able to be set to NULL.

Closes #2289. Thanks to Poltorak Serguei.
This commit is contained in:
Roger A. Light 2021-08-31 10:45:10 +01:00
parent 77af2ecefe
commit 605131502b
2 changed files with 7 additions and 15 deletions

View File

@ -50,6 +50,7 @@ Client library:
- Disable TLS v1.3 when using TLS-PSK, because it isn't correctly configured.
- Threaded mode is deconfigured when the mosquitto_loop_start() thread ends,
which allows mosquitto_loop_start() to be called again. Closes #2242.
- Fix MOSQ_OPT_SSL_CTX not being able to be set to NULL. Closes #2289.
Apps:
- Fix `mosquitto_ctrl dynsec setDefaultACLAccess` command not working.

View File

@ -401,26 +401,17 @@ int mosquitto_opts_set(struct mosquitto *mosq, enum mosq_opt_t option, void *val
{
int ival;
if(!mosq || !value) return MOSQ_ERR_INVAL;
if(!mosq) return MOSQ_ERR_INVAL;
switch(option){
case MOSQ_OPT_PROTOCOL_VERSION:
if(value == NULL){
return MOSQ_ERR_INVAL;
}
ival = *((int *)value);
return mosquitto_int_option(mosq, option, ival);
case MOSQ_OPT_SSL_CTX:
#ifdef WITH_TLS
mosq->ssl_ctx = (SSL_CTX *)value;
if(mosq->ssl_ctx){
#if (OPENSSL_VERSION_NUMBER >= 0x10100000L)
SSL_CTX_up_ref(mosq->ssl_ctx);
#else
CRYPTO_add(&(mosq->ssl_ctx)->references, 1, CRYPTO_LOCK_SSL_CTX);
#endif
}
break;
#else
return MOSQ_ERR_NOT_SUPPORTED;
#endif
return mosquitto_void_option(mosq, option, value);
default:
return MOSQ_ERR_INVAL;
}
@ -512,7 +503,7 @@ int mosquitto_int_option(struct mosquitto *mosq, enum mosq_opt_t option, int val
int mosquitto_void_option(struct mosquitto *mosq, enum mosq_opt_t option, void *value)
{
if(!mosq || !value) return MOSQ_ERR_INVAL;
if(!mosq) return MOSQ_ERR_INVAL;
switch(option){
case MOSQ_OPT_SSL_CTX: