var https = require('https'); var fs = require('fs'); //install openssl, and run //openssl genrsa -out privatekey.pem 1024 //openssl req -new -key privatekey.pem -out certificate.csr //openssl x509 -req -in certificate.csr -signkey privatekey.pem -out certificate.pem var options = { key: fs.readFileSync('privatekey.pem'), cert: fs.readFileSync('certificate.pem') }; https.createServer(options, function (request, response) { response.writeHead(200); response.end("Hello world from HTTPS"); }).listen(8000);