-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinitcert.js
46 lines (39 loc) · 1.04 KB
/
initcert.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
45
46
#!/usr/bin/env node
'use strict';
var path = require('path');
var readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
var cipher = require('./cipher');
var collection;
var keystore = path.resolve(__dirname, 'cert/.woogeen.keystore');
var allComps = ['sample'];
console.log('Will generate passphrase store for basic server.');
cipher.unlock(cipher.k, keystore, function cb(err, obj) {
if (err || typeof collection !== 'object') {
collection = {};
} else {
collection = obj;
}
function done() {
readline.close();
cipher.lock(cipher.k, collection, keystore, function cb(err) {
console.log(err || 'done!');
});
}
function ask(components, end) {
var component = components.splice(0, 1)[0];
if (component) {
readline.question('Enter passphrase of certificate for ' + component +
': ',
function(res) {
collection[component] = res;
ask(components, end);
});
} else {
end();
}
}
ask(allComps, done);
});