-
Notifications
You must be signed in to change notification settings - Fork 17
/
ocsp-server.js
63 lines (50 loc) · 1.53 KB
/
ocsp-server.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* OCSP-Server via OpenSSL
*/
var spawn = require('child_process').spawn;
var log = require('fancy-log');
var ocsp;
/**
* Function starts OpenSSL server
*/
var startServer = function() {
return new Promise(function(resolve, reject) {
log("Starting OCSP server ...")
ocsp = spawn('openssl', [
'ocsp',
'-port', global.config.server.ip+':'+global.config.server.ocsp.port,
'-text',
'-sha256',
'-index', 'index.txt',
'-CA', 'ca-chain.cert.pem',
'-rkey', 'ocsp/ocsp.key.pem',
'-rsigner', 'ocsp/ocsp.cert.pem'
], {
cwd: global.paths.pkipath + 'intermediate',
detached: true,
shell: true
});
// Enter ocsp private key password
ocsp.stdin.write(global.config.ca.intermediate.ocsp.passphrase + '\n');
log(">>>>>> OCSP server is listening on " + global.config.server.ip + ':' + global.config.server.ocsp.port + " <<<<<<");
resolve();
ocsp.on('error', function(error) {
log("OCSP server startup error: " + error);
});
ocsp.on('close', function(code){
if(code === null) {
log("OCSP server exited successfully.");
} else {
log.error("OCSP exited with code " + code);
}
});
});
};
var stopServer = function() {
ocsp.kill('SIGHUP');
log("OCSP server stopped.");
};
module.exports = {
startServer: startServer,
stopServer: stopServer
}