Created
November 21, 2014 23:52
-
-
Save ecasilla/86ab27a6775cefd06e84 to your computer and use it in GitHub Desktop.
Express HTTPS
This file contains hidden or 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
//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