-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathssloptions.js
33 lines (28 loc) · 956 Bytes
/
ssloptions.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
/***
* Built-ins
***/
var fs = require('fs');
/***
* functions
***/
function filter_options(options) {
// take in a dictionary options.
// look for the options "keyfile", "certfile", or "cafile".
// for each option found, remove the option, read in the contents of the
// file, and generate a corresponding option with the file's data.
var preimage=['keyfile','certfile','cafile']
var image=['key','cert','ca']
for(var i=0; i < preimage.length; i++) {
// check if some *file option is defined
if (options.hasOwnProperty(preimage[i])) {
// read in the data right now
var data = fs.readFileSync(options[preimage[i]]);
// remove *file option
delete options[preimage[i]];
// put the data into the correct option
options[image[i]] = data.toString();
}
}
return options;
}
module.exports.filter_options = filter_options;