Reputation: 75
I have created a Node js backend for my React application which is using https protocol. For this :- I created SSL using these commands:-
openssl genrsa 1024 > private.key
openssl req -new -key private.key -out cert.csr
openssl x509 -req -in cert.csr -signkey private.key -out certificate.pem
And then i use that certificate to create Secure Server https:-
var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);
/**
* Create HTTP server.
*/
var server = http.createServer(app);
/**
* Listen on provided port, on all network interfaces.
*/
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);
app.set('secPort',port+443);
/**
* Create HTTPS server.
*/
var options = {
key: fs.readFileSync(__dirname+'/private.key'),
cert: fs.readFileSync(__dirname+'/certificate.pem')
};
var secureServer = https.createServer(options,app);
/**
* Listen on provided port, on all network interfaces.
*/
secureServer.listen(app.get('secPort'), () => {
console.log('Server listening on port ',app.get('secPort'));
});
secureServer.on('error', onError);
secureServer.on('listening', onListening);
My Question is will I get ssl error when i deploy it on heroku? If yes, then what should i do to make it deployable with secure server?
Upvotes: 0
Views: 129
Reputation: 410
You can include self signed certificate but users will see a warning message when coming to your site. Heroku mentions they offer free SSL certificates but that's really not the case unless you have a Hobby ($7/mo) or Pro plan. Although you can get a free certificate, it cannot be included in a free Heroku app.
Upvotes: 1