From 9ecb6aba1a176e11a76071e351d70d0a1d96420a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Nicola?= Date: Wed, 20 Dec 2023 12:08:13 +0100 Subject: [PATCH] Add: support authenticated connection to MQTT broker (#1545) If the scanner options `mqtt_user` and `mqtt_pass` are set, the connection will be authenticated. For this to work, MQTT broker must be configured with valid user and pass This is disable per default --- src/openvas.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/openvas.c b/src/openvas.c index f834cfd99..8c602bc6e 100644 --- a/src/openvas.c +++ b/src/openvas.c @@ -443,7 +443,13 @@ attack_network_init (struct scan_globals *globals, const gchar *config_file) mqtt_server_uri = prefs_get ("mqtt_server_uri"); if (mqtt_server_uri) { +#ifdef AUTH_MQTT + const char *mqtt_user = prefs_get ("mqtt_user"); + const char *mqtt_pass = prefs_get ("mqtt_pass"); + if ((mqtt_init_auth (mqtt_server_uri, mqtt_user, mqtt_pass)) != 0) +#else if ((mqtt_init (mqtt_server_uri)) != 0) +#endif { g_message ("%s: INIT MQTT: FAIL", __func__); send_message_to_client_and_finish_scan (