Skip to content

Instantly share code, notes, and snippets.

@saimonmoore
Forked from 3rd-Eden/ssl.js
Created April 5, 2011 14:00
Show Gist options
  • Save saimonmoore/903642 to your computer and use it in GitHub Desktop.
Save saimonmoore/903642 to your computer and use it in GitHub Desktop.
// Build the https based part & read the key and crt file that is required to encrypte the server / client connection
var ssl = https.createServer({
key: fs.readFileSync( "./ssl/ssl.private.key" ).toString()
, cert: fs.readFileSync( "./ssl/ssl.crt" ).toString()
});
// This is the part what it's all about, we are going to route all
// https based requires to the default app handler
ssl.addListener( "request", function sllRequestListener( req, res ){
req.ssl = true; // just add an extra flag so we can see if it was forwarded from https
app.emit( "request", req, res ); // app is my express instance
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment