1

I need to use node to make a post request with a certificate.

The certificate is held in the windows certificate store. I've been able to read this out with node, but what I get is an object containing the various details for the certificate, the pem, issuer etc.

The files are in the .cer format.

Does anyone know how to use a certificate like this to a post request in node?

OliverRadini
  • 6,238
  • 1
  • 21
  • 46
  • Do you really mean to send a cert with the request, which couldn't provide any kind of security and thus is pretty useless, or do you mean to send a request over HTTPS with client authentication (_using_ a cert _and_ privatekey) in the protocol? Those are wildly different things. If the latter see https://stackoverflow.com/questions/35478215/how-to-do-https-get-with-client-certificate-in-node or https://stackoverflow.com/questions/46894187/nodejs-request-to-a-web-service-with-p12-certificate or else [show us an MCVE](https://stackoverflow.com/help/mcve) – dave_thompson_085 Jun 05 '18 at 11:06
  • I've updated the question to reflect the point you made. I'm not sure I see how the questions help with the problem I'm having; they use pem and p12 certificates from a file. I'm trying to use a .cer certificate from the windows certificate store. – OliverRadini Jun 05 '18 at 11:10
  • '.cer' is not really _a_ format; people use it for both DER and PEM, converting between which is trivial, and those formats are the same whether in a file or not. But you say you have an object -- which cannot be either of them; and '.cer' usually means only a cert and not a privatekey, and you can't do client auth without a privatekey _and_ matching cert (and usually cert _chain_), but the Windows crypto APIs mostly try to hide this difference. This leaves me with no clue what data you actually have so I can't suggest anything. – dave_thompson_085 Jun 06 '18 at 09:20
  • Yes, basically the node module I was using to get to the certificate store got the data as an object, with the data contained in that object relating to that stored in the certificate file. I wasn't able to find a way to get node to use this, so instead I've used edge-js and used c# code to make the request instead, which is working. – OliverRadini Jun 06 '18 at 12:06

0 Answers0