openssl genrsa -out key.pem
openssl req -new -key key.pem -out csr.pem
openssl x509 -req -days 9999 -in csr.pem -signkey key.pem -out cert.pem
rm csr.pemThis should leave you with two files, cert.pem (the certificate) and key.pem (the private key). This is all you need for a SSL connection.
2. So now you set up a quick hello world example (the biggest difference between https and http is the options parameter):
var https = require('https');
var fs = require('fs');
var options = {
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('cert.pem')
};
var a = https.createServer(options, function (req, res) {
res.writeHead(200);
res.end("hello world\n");
}).listen(8000);Now in your browser go to the url: https://localhost:8000