Created
December 24, 2013 07:03
-
-
Save furqanZafar/8109773 to your computer and use it in GitHub Desktop.
Create SSL server using express (nodejs)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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