nodejs / help

:sparkles: Need help with Node.js? File an Issue here. :rocket:
1.44k stars 276 forks source link

Error while making httpsAgent call using pfx certificate and Axios #4315

Open sidhartha31 opened 6 months ago

sidhartha31 commented 6 months ago

Details

I tried to use Axios with an https.Agent with pfx configuration but I get the below error message:

Error: unsupported

I checked https://github.com/axios/axios/issues/4778 and I applied the fix but it still didn't work. After that, I added a .npmrc file and by adding the node-options parameter there, it started working. The line that was added is:

node-options="--openssl-legacy-provider"

Can you please inform in which version of Node 18.x can I use my current setup without making use of .npmrc file? It won't be possible for me to downgrade the Node version. And if I have to use the .npmrc file, does it introduce any security threat?

Node.js version

18.8.2

Example code

const configuredHttpsAgent = new https.Agent({
  pfx: KEYFILE_CONTENT,
  passphrase: PASSPHRASE
});

const config = {
    method: 'post',
    url,
    headers,
    data: body,
    httpsAgent: configuredHttpsAgent
  };
  axios(config)
    .then((response) => {
      // successfully sent notification
    })
    .catch((error) => {
      req.logger.error("${error}");
    });

Operating system

Linux

Scope

Runtime

Module and version

Not applicable.

camilo-pinheiro commented 2 months ago

Try to use node 16