Saturday, 31 August 2013

In NodeJS, how do I specify one ca certificate for client certificate checking, and another for showing the certificate chain to the...

In NodeJS, how do I specify one ca certificate for client certificate
checking, and another for showing the certificate chain to the...

I'm trying to write a program that uses client certificate authentication
as my primary authentication method. I have a certificate signed for my
website that I want to have this application use. I read
http://blog.nategood.com/nodejs-ssl-client-cert-auth-api-rest and was
going to implement my server as described by this person's article, but I
would like to present my signed certificate to browsers, and then sign
certificates they generate with the keygen attribute with my own
certificate authority.
example code:
var https = require("https");
var http = require("http");
var fs = require("fs");
var options = {
key:fs.readFileSync("./myserver.key"),
cert:fs.readFileSync("./server.crt"),
ca:fs.readFileSync("server.ca_bundle"),
//I want to have a separate certificate for checking client
certificates here, but I would be ok with any solution to the problem.
requestCert:true,
rejectUnauthorized: false
};
https.createServer(options, function (req, res) {
res.writeHead(200, "Content-type: text/plain");
res.write("Authorized: "+JSON.stringify(req.client.authorized))
}).listen(443);

No comments:

Post a Comment