Answer the question
In order to leave comments, you need to log in
How to correctly connect an SSL certificate to a nodeJS application?
I have a working nodeJS application. It uses standard packages:
– socket.io
– fs
– request
– mysql I saw this code
on ru.stackoverflow.com . Despite the fact that I do not use redis and express, I do not understand in what format it is necessary to push the crt certificates!
var app = require('express')();
var redis = require('redis');
var server = require('https').createServer({
key: fs.readFileSync('server.key'),
cert: fs.readFileSync('server.crt')
},app);
var io = require('socket.io')(server);
server.listen(8890);
io.on('connection', function (socket) {
console.log("new client connected");
var redisClient = redis.createClient();
redisClient.subscribe('notification');
redisClient.on("message", function(channel, message) {
console.log("New message: " + message + ". In channel: " + channel);
socket.emit(channel, message);
});
socket.on('disconnect', function() {
redisClient.quit();
});
});
Answer the question
In order to leave comments, you need to log in
pem
example .
var privateKey = fs.readFileSync( 'privatekey.pem' , 'utf8');
var certificate = fs.readFileSync( 'certificate.pem', 'utf8');
https.createServer({
key: privateKey,
cert: certificate
}, app).listen(port);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question