uNetworking / uWebSockets.js

μWebSockets for Node.js back-ends :metal:
Apache License 2.0
8.08k stars 574 forks source link

Change ssl certificate without dropping connections #868

Closed abhay-s-rawat closed 1 year ago

abhay-s-rawat commented 1 year ago

Hi , I am using uWebSockets.js with socketio and I was searching for way to update ssl certificate when ssl renews without restarting server. Like its done with httpserver. I can use filewatcher to know if certificate is renewed, can you please tell how to change in uWebSockets.js.

httpServer.setSecureContext(
{
  key: fs.readFileSync(settings.PRIVKEY),
  cert: fs.readFileSync(settings.FULLCHAIN)
});
const { SSLApp } = require("uWebSockets.js");
const { Server } = require("socket.io");

const app = new SSLApp({
  key_file_name: "keys/server_key.pem",
  cert_file_name: "keys/server_cert.pem",
});
const io = new Server({ transports: ["websocket"] });
io.attachApp(app);
uNetworkingAB commented 1 year ago

You can use the SNI feature for this.