Skip to content

How to use TLS/SSL two-way authentication connections in browser? #1515

@ysfscream

Description

@ysfscream

Hi, guys. I want to use two-way authentication when connecting using WebSocket, but when I use the client certificate, it shows that the connection has failed, so I would like to ask how to use TLS/SSL two-way authentication in the browser?

I am very sorry for the disturbance, I would be very grateful.

Currently, I am configuring the contents of the ca, cert and key files directly into options in the code, but I can't use them, unlike when using TCP connections.

const { host, port, endpoint, ...options } = this.connection
options.rejectUnauthorized = true
options.ca = certs.ca
options.cert = certs.sert
options.key = certs.key
const connectUrl = `wss://${host}:${port}${endpoint}`
this.client = mqtt.connect(connectUrl, options)

Because I tested it, it will connect fine if I don't use WebSocket.

The only error message I get is that the connection failed. I think it's an error when creating a new WebSocket client.

image

@YoDaMa

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions