We're making HTTPS calls from Node.js that require use of a client certificate. The certificate/key & associated password are read in from file and this all works. My concern though is having to read in the files for every request and the question is what is the best way to cache this.
Would using the apigee-access module to access the Edge distributed cache be the appropriate thing to do in these circumstances? Or would it be better to use one of the Node file caches that are available?
Solved! Go to Solution.
When i did a similar implementation - i just loaded my cert during initialization, and not in the request handler. So the request handlers need not load the files everytime. But the downside to that is, it is permanently loaded.
When i did a similar implementation - i just loaded my cert during initialization, and not in the request handler. So the request handlers need not load the files everytime. But the downside to that is, it is permanently loaded.
@Mukundha Madhavan - do you know if there is any documentation on where / how initialisation is done? I'm struggling to find any.
the script will be run when the proxy is deployed, so behavior is similar to how you run a simple http server in node -
so for eg, you can do something like
cert = fs.readFileSync('mycert.pem') app.get('/foo',function(req,res){ //use cert here }) app.post('/bar',function(req,res){ //use cert here }) app.listen(8080)
the request handlers are only called based on the incoming request, however the script itself is run during deployment [so cert will be set when you deploy the proxy],
var cert = fs.readFileSync('mycert.pem'); // runs at deploy time // register the .get handler at deploy time app.get('/foo',function(req,res){ // use cert here; this happens only at the time a GET request arrives }); // register the .get handler at deploy time app.post('/bar',function(req,res){ // use cert here; this happens only when a POST request arrives }); app.listen(8080); // happens at deploy time
Type a product name