Phoenix SLL certificate and communication with MQTT SSL via Tortoise library

mix
phoenix
deployment
testing
troubleshooting

#1

I have a phoenix project in which I wrote command mix phx.gen.cert that is generating me certificates. Adding the certifile and keyfile paths to dev.exs

config :api, ApiWeb.Endpoint,
    http: [port: 4000],
    https: [
      port: 4002,
      cipher_suite: :strong,
      certfile: "priv/cert/selfsigned.pem",
      keyfile: "priv/cert/selfsigned_key.pem"
    ],

When I open https://localhost:4002 it says the connection is not secured and cert is not valid.
I also have a MQTT mix project where I have to connect to the phoenix through SSL.
Using Tortoise library - https://github.com/gausby/tortoise

Tortoise.Supervisor.start_child(
    client_id: "smart-spoon",
    handler: {Tortoise.Handler.Logger, []},
    server: {
      Tortoise.Transport.SSL,
      host: host, port: port,
      cacertfile: :certifi.cacertfile(),
      key: key, cert: cert
    },
    subscriptions: [{"foo/bar", 0}])

This is the code I am suposed to use for connection.
So basically I have to generate certificate for each client who connects to the MQTT.
I have no idea how this is done and I didn’t find a lot of documentations that are more than 5 sentences.

Just to notice, with TCP (no ssl) the MQTT communication and functionallity are working perfectly.

Also should the mix project for the MQTT be integrated in Phx project?