Nodejs - Windows Key/Certificate store

不打扰是莪最后的温柔 提交于 2019-12-11 10:17:49

问题


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


回答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);
  }
});



回答2:


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

  • https://github.com/jfromaniello/node-windows-certs
  • https://www.npmjs.com/package/windows-certs

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:

  • https://www.npmjs.com/package/win-ca
  • https://github.com/ukoloff/win-ca



回答3:


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();


来源:https://stackoverflow.com/questions/16863113/nodejs-windows-key-certificate-store

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!