ESP8266 with Mosquitto server over TLS(SSL) using username and password

Hi I am new to the whole IoT and esp8266. I am using Arduino IDE to program NodeMCU. I have setup a mosquitto server runing on AWS EC2. I have used certbot in standalone mode to download TLS certificates from lets-encrypt against my domain name.
I have configured the mosquitto server to use the certificate files and listen on 8883 port for secure mqtt connection. Also it needs an username and password for client authentication.
I am using mqtt.fx as a client on my laptop to connect to the secure mqtt server (Over TLS and with username and pass) and it works fine.
Here is the client's configuration

Now I am trying to connect to the same MQTT server from a nodeMCU using adafruit_MQTT_Client.h Library.
I cant not seem to get it to connect.

I am getting a response from the MQTT server saying "Connection Refused".
I have tested the same library with flespi and adafruit and it has worked. The catch is though those mqtt brokers use token based authentication orver TLS but in my server I have username and password based authentication over TLS. I did not find any example of this library using username and password based authentication over TLS. Can anyone help me with this please.

All I am looking for is a code that can connect to a mosquitto broker over TLS using username and password authentication.

Thank you.

Might be of help?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.