Nodejs - Windows Key/Certificate store
Asked Answered
K

4

1

Does anybody have any pointers as to how I could go about interacting with the Key/Certificate store using nodeJs? I specifically want to add/remove certificates and possibly keys.

Update.

So the way to go here is to use "edge". Very nice work!

https://github.com/tjanczuk/edge

Kessiah answered 31/5, 2013 at 17:53 Comment(0)
M
1

Without knowing too much about your setup here is a stab at a 'pointer' as to how to interact.

You could try using Nodes Child Process and then spawning out a process to the commandline and interact with the key/certificate store the way you would via command line. Microsofts certificate manager tool perhaps?

Rough example:

var exec = require('child_process').exec,
child;

child = exec('certmgr /add /all /c myFile.ext newFile.ext', 

function (error, stdout, stderr) {
  console.log('stdout: ' + stdout);
  console.log('stderr: ' + stderr);
  if (error !== null) {
    console.log('exec error: ' + error);
  }
});
Marcos answered 31/5, 2013 at 19:12 Comment(3)
Excellent, that would be a fairly safe bet. However, I was wondering if there was a way to do it without having to call the command line.Kessiah
A quick search of npmjs.org doesn't look promising for a module. There's nothing in the base program that does this.Grammar
Have you had a look through the NPM registry for any packages that might help?Marcos
S
1

I've just published node-windows-root-certs which uses ffi to read the windows root certificate store, and then apply these in nodejs... may provide some inspiration.

Example use to use Windows certificates rather than internal NodeJS certificates:

var windowsRootCerts = require('node-windows-root-certs');
// to read the windows root certs and patch in a single command:
windowsRootCerts.useWindowsCerts();
Selhorst answered 14/10, 2019 at 11:24 Comment(0)
A
0

There is an npm package 'windows-certs' which uses edge and a .csx script to read certificates in .pem format

This should have the required functionality, but is marked as deprecated. The successor package is indicated as.win-ca. However, this seems to be lacking some of the functionality of the older package:

Alidis answered 23/9, 2015 at 9:56 Comment(3)
now deprecated, github note says 'use github.com/ukoloff/win-ca' but it's a little differentPhilomena
You mean successor not predecessor. But windows-certs did and win-ca does only read and this Q asks to 'add/remove'.Consolatory
Original answer was edited, apparently broken, and now I get down votes! I will re-expand.Alidis
T
0

The following code works for me.

// https://github.com/ukoloff/win-ca#inject
const ca = require('win-ca')
ca.inject('+')
Tannenberg answered 6/9, 2023 at 6:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.