Answer the question
In order to leave comments, you need to log in
How to set up a socket connection with SSL?
Good afternoon, dear ones.
I must say right away that I have not yet worked with nodejs and sockets and I can formulate something incorrectly in the question, thanks.
In general, I came across one laravel project that runs on nodejs.
It works like this, nodejs is launched on the server and listens for client connections on a specific port.
Everything works fine without using ssl, but since the site works on SSL, when the client connects to the server, this error occurs:
WebSocket connection to 'wss://domain.com:9031/' failed: Error in connection establishment: net::ERR_CERT_AUTHORITY_INVALID
var privateKey = fs.readFileSync('ssl/domain.com.key', 'utf8');
var certificate = fs.readFileSync('ssl/domain.com.crt', 'utf8');
var credentials = { key: privateKey, cert: certificate };
var https = require('https');
var httpsServer = https.createServer(credentials);
httpsServer.listen(serverConfig.port);
var WebSocket = require('ws').Server;
var wss = new WebSocket({
server: httpsServer
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question