Skip to content

Instantly share code, notes, and snippets.

@mrroot5
Last active March 2, 2020 09:45
Show Gist options
  • Save mrroot5/f15f51caa1e52818c50d496dc51eadd1 to your computer and use it in GitHub Desktop.
Save mrroot5/f15f51caa1e52818c50d496dc51eadd1 to your computer and use it in GitHub Desktop.
Nodejs ssl cert https express

Generar certificado

openssl req -nodes -new -x509 -keyout server.key -out server.cert

Server express config

var express = require('express')
var fs = require('fs')
var https = require('https')
var app = express()

app.get('/', function (req, res) {
  res.send('hello world')
})

https.createServer({
  key: fs.readFileSync('server.key'),
  cert: fs.readFileSync('server.cert')
}, app)
.listen(3000, function () {
  console.log('Example app listening on port 3000! Go to https://localhost:3000/')
})

Fuente

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment