4

I don't understand how I can use my .p12 certificate in an axios request.

I found this :

const fs = require('fs');
const https = require('https');
const axios = require('axios');

// ...
const httpsAgent = new https.Agent({
  cert: fs.readFileSync('client.crt'),
  key: fs.readFileSync('client.key'),
  ca: fs.readFileSync('ca.crt'),
});

const result = await axios.get('https://myserver.internal.net:9443', { httpsAgent });
// do something with the result

// ...

But I don't know enough about nodeJS to understand if this is the right method.

I have to convert my .p12 ?

Regards

Kalènas
  • 43
  • 3
  • Your code looks correct. Ref [axios issue 284](https://github.com/axios/axios/issues/284) and [this SO question](https://stackoverflow.com/a/53585725/1424869). Is it not working for you? If not, what errors are you seeing? – Chris Camaratta Mar 21 '21 at 21:39

0 Answers0