Socket.io client API documentation suggests that the client should pass the self signed certificate in the connection request to the server:
// client-side
const socket = io({ca: fs.readFileSync('server-cert.pem'),rejectUnauthorized: false});
This works great in a node environment.
How to make this work in a BROWSER javascript app? I am facing two issues:
- How can I include the certificate file in the browser app? readfileSync cannot find the file
- If I only include rejectUnauthorized: false in the options, it works fine for node, but still doesn't work in the browser (Firefox, Chrome)
I have tried everything, such as below but nothing is working
https.globalAgent.options.rejectUnauthorized = false;
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
Is my only option to get a properly signed certificate?