Skip to content

Instantly share code, notes, and snippets.

@ecasilla
Created November 21, 2014 23:52
Show Gist options
  • Save ecasilla/86ab27a6775cefd06e84 to your computer and use it in GitHub Desktop.
Save ecasilla/86ab27a6775cefd06e84 to your computer and use it in GitHub Desktop.
Express HTTPS
//run in the command line one at a time
//openssl genrsa -out privatekey.pem 1024
//openssl req -new -key privatekey.pem -out certreq.csr
//openssl x509 -req -days 3650 -in certreq.csr -signkey -private.pem -out newcert.pem
var express = require('express'),
https = require('https'),
fs = require('fs');
privateKey = fs.readFileSync('path/to/privateKey.pem'),
cert = fs.readFileSync('path/to/newCert.pem'),
options = {key:privateKey,cert:cert},
app = express();
app.get('*',function(){
res.end('I am batman\n')
});
https.createServer(options,app)
.listen(9000,function(){
console.log("You have a secure connection to the president\n")
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment