Skip to content

ca support #18

@donnie-kerr

Description

@donnie-kerr

I am trying to connect to a broker via WSS using a ca cert. I is failing to connect and a in the error is undefined so I do not know why it is failing. Is this method of connecting using a pem file supported? If not, how do I change it to at least get an error back?
`async loadCert() {

  const response = await fetch('ca-chain.pem');
  return await response.text();
},
async connectMqtt() {
  const clientIdUnique = Math.random().toString(16).substring(2, 10);
  
 const protocol = 'wss'
 const host = `XXXX`
 const port = 8882
 
  const options = {
    clientId: `aiassistant`,
    clean: true,
    keepalive: 60,
    protocolId: "MQTT",
    username:"XXXX",
    password:"XXXX",
    ca: [await this.loadCert()],
  };


  this.mqttClient = mqtt.connect(
    `${protocol}://${host}:${port}`,
    options
  );

this.mqttClient.on("error", function (a) {
console.log("error!" + a);
});
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions