]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/lib/config/load-cafile.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / lib / config / load-cafile.js
1 module.exports = loadCAFile
2
3 var fs = require("fs")
4
5 function loadCAFile(cafilePath, cb) {
6   if (!cafilePath)
7     return process.nextTick(cb)
8
9   fs.readFile(cafilePath, "utf8", afterCARead.bind(this))
10
11   function afterCARead(er, cadata) {
12
13     if (er) {
14       // previous cafile no longer exists, so just continue on gracefully
15       if (er.code === 'ENOENT') return cb()
16       return cb(er)
17     }
18
19     var delim = "-----END CERTIFICATE-----"
20     var output
21
22     output = cadata
23       .split(delim)
24       .filter(function(xs) {
25         return !!xs.trim()
26       })
27       .map(function(xs) {
28         return xs.trimLeft() + delim
29       })
30
31     this.set("ca", output)
32     cb(null)
33   }
34 }