Skip to content

Instantly share code, notes, and snippets.

@kolserdav
Created January 22, 2020 07:50
Show Gist options
  • Save kolserdav/0a74764e67541c1caceae783150885a5 to your computer and use it in GitHub Desktop.
Save kolserdav/0a74764e67541c1caceae783150885a5 to your computer and use it in GitHub Desktop.
NodeJs Express SSL certigicate
const app = require('express')();
const https = require('https');
const fs = require('fs');
//GET home route
app.get('/', (req, res) => {
res.send('Hello World');
});
//openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365
// we will pass our 'app' to 'https' server
https.createServer({
key: fs.readFileSync('./key.pem'),
cert: fs.readFileSync('./cert.pem'),
passphrase: 'YOUR PASSPHRASE HERE'
}, app)
.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment