Reputation: 343
I am currently implementing a NodeJS server, which runs on windows machine. My requirement is to enable certificate validation for client server commnunication. Currently, I have my code as below and works great (note that all the clients are sent the server Root CA certificate).
var ssl_options = {
key: fs.readFileSync(options.key),
cert: fs.readFileSync(options.cert),
ca: null
};
server = https.createServer(ssl_options, function (request, response) {
// server logic
}
But, my requirement is to use an already existing certificate from the windows store and I am not able do it properly without extracting the private key from the certificate.
I tried using the Httpsys module and it works fine but looks like it is a pretty new module which is not yet tested properly. So, wanted to know if there is any other alternative to use the windows certificate directly in Nodejs without extracting the key.
Upvotes: 12
Views: 9480
Reputation: 4899
You can take a look at npm module https://www.npmjs.com/package/windows-certs and use it in your application or reuse it's code. The idea is pretty simple - you start your application, export certificate to ram and then use for ssl connection. Initial format conversions should not matter.
Upvotes: 0