Skip to content

Instantly share code, notes, and snippets.

@furqanZafar
Created December 24, 2013 07:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save furqanZafar/8109773 to your computer and use it in GitHub Desktop.
Save furqanZafar/8109773 to your computer and use it in GitHub Desktop.
Create SSL server using express (nodejs)
### GENERATE PRIVATE KEY (key.pem)
# openssl req -newkey rsa:2048 -new -nodes -keyout key.pem -out csr.pem
### GENERATE CERTIFICATE (cert.pem)
# openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem
express = require("express")
fs = require('fs')
https = require('https')
app = new express()
app.use(express.logger())
app.get("/", (req, res)-> res.send("ssl mode!"))
options = {
key: fs.readFileSync('key.pem')
cert: fs.readFileSync('cert.pem')
}
https.createServer(options, app).listen(443)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment