Skip to content

Instantly share code, notes, and snippets.

@PaulSec
Created July 8, 2015 10:47
Show Gist options
  • Save PaulSec/4466bc6d578c5d15c556 to your computer and use it in GitHub Desktop.
Save PaulSec/4466bc6d578c5d15c556 to your computer and use it in GitHub Desktop.
Service static cert using Node.js
var http = require('http'),
path = require('path'),
fs = require('fs');
http.createServer(function(req, res) {
filename = './cacert.crt'
path.exists(filename, function(exists) {
res.writeHead(200, {'Content-disposition': 'attachment; filename=cacert.crt', 'Content-Type': 'text/plain'});
var fileStream = fs.createReadStream(filename);
fileStream.pipe(res);
}); //end path.exists
}).listen(1337);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment