Skip to content

Commit

Permalink
New PKI workz like a charm :-) OCSP working as well. Nice!
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Leister committed Feb 10, 2017
1 parent 63bffba commit c44d38c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions api/certificate.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ certificate.request = function(req, res){
fs.writeFile(tempdir + 'request.csr', csr, function(err) {
if(err === null) {
// OpenSSL command template
var signcommand = util.format('openssl ca -batch -config %sopenssl.cnf -extensions server_cert -days 1 -notext -md sha256 -in request.csr -key "%s" -out cert.pem', global.paths.pkipath, global.config.ca.passphrase);
var signcommand = util.format('openssl ca -batch -config %s/intermediate/openssl.cnf -extensions server_cert -days 1 -notext -md sha256 -in request.csr -key "%s" -out cert.pem', global.paths.pkipath, global.config.ca.intermediate.passphrase);

// Execute Linux Shell command
exec(signcommand, { cwd: tempdir }, function(error, stdout, stderr) {
Expand Down Expand Up @@ -151,7 +151,7 @@ certificate.revoke = function(req, res){
if(err === null) {
// Execute OpenSSL command
log.info("Executing OpenSSL command.")
var revokecommand = util.format('openssl ca -config %sopenssl.cnf -revoke cert.pem -key "%s"', global.paths.pkipath, global.config.ca.passphrase);
var revokecommand = util.format('openssl ca -config %sintermediate/openssl.cnf -revoke cert.pem -key "%s"', global.paths.pkipath, global.config.ca.intermediate.passphrase);

exec(revokecommand, { cwd: tempdir }, function(error, stdout, stderr) {
if (error === null) {
Expand Down
2 changes: 1 addition & 1 deletion certdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var reindex = function() {

// Index-Datei öffnen
var lineReader = require('readline').createInterface({
input: require('fs').createReadStream('./mypki/index.txt')
input: require('fs').createReadStream('./mypki/intermediate/index.txt')
});

certificates = [];
Expand Down
7 changes: 6 additions & 1 deletion genpki.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,12 @@ var createIntermediateCA = function() {
fs.removeSync(pkidir + 'intermediate/intermediate.csr.pem');

// Create CA chain file
// TO BE DONE
// Read intermediate
intermediate = fs.readFileSync(pkidir + 'intermediate/intermediate.cert.pem', 'utf8');
// Read root cert
root = fs.readFileSync(pkidir + 'root/root.cert.pem', 'utf8');
cachain = intermediate + '\n\n' + root;
fs.writeFileSync(pkidir + 'intermediate/ca-chain.cert.pem', cachain);

resolve();
});
Expand Down
8 changes: 4 additions & 4 deletions ocsp-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ var startServer = function() {
'-text',
'-sha256',
'-index', 'index.txt',
'-CA', 'certs/ca.cert.pem',
'-rkey', 'private/ocsp.key.pem',
'-rsigner', 'certs/ocsp.cert.pem'
'-CA', 'ca-chain.cert.pem',
'-rkey', 'ocsp/ocsp.key.pem',
'-rsigner', 'ocsp/ocsp.cert.pem'
], {
cwd: "mypki/",
cwd: "mypki/intermediate",
detached: true,
shell: true
});
Expand Down

0 comments on commit c44d38c

Please sign in to comment.