How to use .p12 certificat with axios (client) in NodeJS

Viewed 660

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

0 Answers
Related