Created
October 4, 2016 06:04
-
-
Save cookie-ag/de29b4d056c54b30a0d8211e9afdb93a to your computer and use it in GitHub Desktop.
Simple HTTPS express 4.x server
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
// Create self-signed certificate using $ openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 | |
// Key is certificate key and cert.pem is certificate file | |
var fs = require('fs'), | |
https = require('https'), | |
express = require('express'), | |
app = express(); | |
https.createServer({ | |
key: fs.readFileSync('key.pem'), | |
cert: fs.readFileSync('cert.pem') | |
}, app).listen(55555); | |
app.get('/', function (req, res) { | |
res.header('Content-type', 'text/html'); | |
return res.end('<h1>Hello, Secure World!</h1>'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment