diff --git a/ChangeLog.txt b/ChangeLog.txt index 880ef88a..8309cf46 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -8,6 +8,7 @@ Broker: Clients: - Set `receive-maximum` to not exceed the `-C` message count in mosquitto_sub and mosquitto_rr, to avoid potentially lost messages. Closes #2134. +- Fix TLS-PSK mode not working with port 8883. Closes #2152. Build: - A variety of minor build related fixes, like functions not having previous diff --git a/client/client_shared.c b/client/client_shared.c index f60b98be..97ee5660 100644 --- a/client/client_shared.c +++ b/client/client_shared.c @@ -1263,6 +1263,14 @@ int client_opts_set(struct mosquitto *mosq, struct mosq_config *cfg) mosquitto_lib_cleanup(); return 1; } +# ifdef FINAL_WITH_TLS_PSK + }else if(cfg->psk){ + if(mosquitto_tls_psk_set(mosq, cfg->psk, cfg->psk_identity, NULL)){ + err_printf(cfg, "Error: Problem setting TLS-PSK options.\n"); + mosquitto_lib_cleanup(); + return 1; + } +# endif }else if(cfg->port == 8883){ mosquitto_int_option(mosq, MOSQ_OPT_TLS_USE_OS_CERTS, 1); } @@ -1295,13 +1303,6 @@ int client_opts_set(struct mosquitto *mosq, struct mosq_config *cfg) mosquitto_lib_cleanup(); return 1; } -# ifdef FINAL_WITH_TLS_PSK - if(cfg->psk && mosquitto_tls_psk_set(mosq, cfg->psk, cfg->psk_identity, NULL)){ - err_printf(cfg, "Error: Problem setting TLS-PSK options.\n"); - mosquitto_lib_cleanup(); - return 1; - } -# endif if((cfg->tls_version || cfg->ciphers) && mosquitto_tls_opts_set(mosq, 1, cfg->tls_version, cfg->ciphers)){ err_printf(cfg, "Error: Problem setting TLS options, check the options are valid.\n"); mosquitto_lib_cleanup();