-
Notifications
You must be signed in to change notification settings - Fork 17
/
publicDl.js
44 lines (33 loc) · 1.6 KB
/
publicDl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
var fs = require('fs-extra')
var publicpath = '/public'
/**
* Initializes API paths.
*/
var initPublicDl = function(app) {
app.get(publicpath + '/ca/root/cert', function(req, res) {
var certificate = fs.readFileSync(global.paths.pkipath + 'root/root.cert.pem')
var filename = global.config.ca.root.commonname.replace(/\ /g, '_').toLowerCase()
res.setHeader('Content-disposition', 'attachment; filename=' + filename + '.cert.pem');
res.setHeader('Content-type', 'application/x-pem-file')
res.end(certificate)
});
app.get(publicpath + '/ca/intermediate/cert', function(req, res) {
var certificate = fs.readFileSync(global.paths.pkipath + 'intermediate/intermediate.cert.pem')
var filename = global.config.ca.intermediate.commonname.replace(/\ /g, '_').toLowerCase()
res.setHeader('Content-disposition', 'attachment; filename=' + filename + '.cert.pem');
res.setHeader('Content-type', 'application/x-pem-file')
res.end(certificate)
});
app.get(publicpath + '/ca/intermediate/crl', function(req, res) {
var certificate = fs.readFileSync(global.paths.pkipath + 'intermediate/crl/crl.pem')
var filename = global.config.ca.intermediate.commonname.replace(/\ /g, '_').toLowerCase()
console.log(filename)
res.setHeader('Content-disposition', 'attachment; filename=' + filename + '.crl.pem');
res.setHeader('Content-type', 'application/x-pem-file')
res.end(certificate)
});
};
// Export initAPI() function (called by server.js)
module.exports = {
initPublicDl: initPublicDl
}