Hi,
I am trying to make my MQTT server more secure by making it ask for a username and password to send messages.
I understand that you can use code like the following to make it ask for a username and password as soon as B4A, B4i & B4J clients connect:
mo.Initialize("user","pass")
However, that username and password will be used by all clients and can't control which username has logged in etc.
Is there a way to make it ask for user/pass when sending or subscribing to a topic ?
If I was to modify the CreateMessage sub like:
Type Message (Body as string, From as String, User as string, Pass as string)
Private Sub CreateMessage(body as string) as byte()
Dim m as Message
m.Initialize
m.body = body
m.from = currentname
m.user = "username"
m.pass = "password"
End Sub
Then when the incoming message is received at the B4J end, receive the user/pass string from the message and check my database to see if the username and password is in the database before processing this message on my server.
Is that the best way in doing this, or is there a more secure way in doing it ?